home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
prog
/
c
/
adev1120.lha
/
BEGINNERS_README
< prev
next >
Wrap
Text File
|
1992-09-18
|
4KB
|
83 lines
INTRODUCTION
NOTE: SOME OF THESE PROGRAMS REQUIRE AMIGADOS 2.0
This development system uses some features and methods that may not be
familiar to you if you have used only simple assemblers in the past. This
note should explain everything - I hope.
The process of generating an S-record file with this system is the same
as for producing an executable from C source with a C compiler. You
first compile/assemble which produces relocatable .o file(s) and then link
the .o file(s) to produce an executable/S-record file.
The reason for these two phases is modularity. The larger the project, the
more you need to segment it into managable units (modules). This reduces
regeneration time since only those modules that have been changed need to
be re-assembled. In the source code, segments are used much like ORG
statements, which they replace, but they allow much greater flexibilty by
leaving address determination until the link stage. Segments make it
possible to have re-usable modules and, in conjunction with the linker,
allow the different modules to create code that does not overlap or
conflict or extend beyond the bounds of available memory.
When more than one module is used, segments are used in conjunction with the
XREF and XDEF statements which tell the assembler which labels are defined
outside of this module (XREF) and which labels from this module are to
be made available to other modules (XDEF). For example, if module A wishes
to access a symbol from module B, module A must XREF it and module B must
XDEF it. The advantage of XREF/XDEF is that symbol clashes are eliminated.
If four modules all define a symbol atemp and do not XDEF it, the four
symbols are unique - changing the contents of one does not change the
contents of the others. If the four modules need a common symbol then ONE
module defines it and XDEF's it, the others that need it XREF it.
The two phases are individually invoked as shown in the simple example
below; in all but the simplest cases you would use a make file and the
'with' option of slink.
SAsm motor.asm
slink from motor.o to motor.sr mem 4000-5000 CODE
Notice the use of CODE in the mem-spec. The name must be the name of a
segment that you have defined. To define a segment in your source create
a line like this;
RSEG CODE
The name can be anything you like but the names CODE and DATA are commonly
used; CODE for the portion that might go into ROM/EPROM/EEPROM, DATA for
the portion that might go into RAM (generally containing mostly RMB's). If
the entire program runs from RAM then just use CODE - BUT the statement
must appear before any RMB's or opcodes otherwise they go into a default
segment (the name of which I can't remember).
If you want an S9 (start address) record to be generated, one source file
must have a label after an end statement as shown here.
END start
This tells the assembler to generate a relocatable S9 record which the
linker will use to produce an S9 record in the output file. As a side
note any other time the END statement is optional.
Part of the advantage of segments and modules is that the ones that are
commonly used can be kept in a library and linked with your program.
Linking with a library is different than linking with a list of modules,
only those parts of the library that are needed are included, as
determined from unresolved references to symbols after linking the modules.
This release contains a library containing functions that I commonly use.
It also contains a librarian (Slib) that you can use to build your own
library or modify mine.
Another advantage of segments and the deferred memory placement (linking)
that that entails is that code, such as utilities and functions, that you
sweat and toil to produce can be delivered to another person without
delivering the source. The user can still place it into his memory map
but, without reverse engineering it, he cannot steal or modify it.
If the use of RSEG instead of ORG still seems like an unjustifiable change,
understand that I did not invent it. You will find SEG's, RSEG's or something
very similar in use in all professional assemblers. In time you will come to
understand the value of them.