ADEV11 Development System for AmigaDOS Version 2.0 A 68HC11 C compiler, assembler, linker, librarian and downloader for the Amiga Public Domain Stan Burton 1978 26 St. SE Medicine Hat, Alta, CANADA T1A 2G8 Table of Contents SECTION 1: Users Manual  1.1 SAsm 1  1.2 SC11 12  1.3 SDis 19  1.4 SLib 21  1.5 SLink 22 SECTION 2: Lib11 Library Reference  2.1  SECTION 3: Examples  3.1 Monitor SECTION 4: Utilities  4.1 HCLoad  4.2 MHex ADEV11 Development System for AmigaDOS Users Manual Version 2.0Acknowledgements I would like to acknowledge the assistance and cooperation of a number of people that have contributed to the improvement of this product either through the supply of files to incorporate into the distribution or their services as bug finders and reporters. Contributions Paul Isaacs - AmigaGuide version of the documents Ron Eirich - HCload utility Bug reports Paul Issacs, Keith Vasilakes ...NAME SAsm SYNOPSIS SAsm [options] [options] DESCRIPTION SAsm is the assembler for the DEV11 system. It is a high level macro cross assembler for the Motorola 6803, 6805, 68HC11 and 68HC16 families and for the Hitachi 6303 family. It is a highly modified version of the publicly distributable DASM V2.12. The 68HC16 code generation has not been well tested since I do not have an HC16 to test it on. If you find any problems with it let me know (Stan). SAsm produces a relocatable file which can be linked together (Slink) with other modules and/or library elements to produce an executable file. Naturally this includes the ability to have multiple segments within a module and BSS or uninitialized segments. (C)Copyright 1987,1988 Matthew Dillon, All Rights Reserved (C)Copyright 1992,1993 Stan Burton, All Rights Reserved Publicly distributable for non-profit only. Must be distributed as is, with NO CHANGES to the documentation or code. COMMAND LINE srcfile: if no extension is specified in the name, .a is added outfile: if no other output file is specified the file generated is the extension-less srcfile name with a .o extension The following options are available: -l[name] generate list file, if no name is specified extension-less srcfile with .lst extension is used -oname generate output to a specific file -s[name] generate symbol file, if no name is specified extension-less srcfile with .sym extension is used -v# select verboseness 0-4 (default 0, see below) 0 (default) Only warnings and errors are generated 1 Segment list information is generated after each pass, Include file names are displayed and reasons why another pass is required are given. 2 Mismatches between program labels and equates are displayed on every pass (usually none occur in the first pass unless you have re-declared a symbol name). 3 Unresolved and unreferenced symbols are displayed every pass (unsorted, sorry) 4 An entire symbol list is displayed every pass to STDOUT. (unsorted, sorry) -p# select number of passes 2-9 (default 2) -d debug mode -DSYMBOL predefine a symbol, set to 0 -DSYMBOL=EXPRESSION predefine a symbol, set to expression Example: asm master.asm -lram:list -v3 -DVER=4 The verbose options can provide additional information about reasons for failure to assemble a file. Part of this is the reason code: R1,R2 reason code: R3 where R1 is the number of times the assembler encountered something requiring another pass to resolve. R2 is the number of references to unknown symbols which occured in the pass (but only R1 determines the need for another pass). R3 is a BITMASK of the reasons why another pass is required. See the end of this document for bit designations. -expressions, as in C. (all expressions are computed with 32 bit integers) -no real limitation on label size, label values are 32 bits. -complex pseudo ops, repeat loops, macros, etc.... The following special characters are used in the symbol dump: ???? unknown value str symbol is a string eqm symbol is an eqm macro (r) symbol has been referenced (s) symbol created with SET or EQM pseudo-op LABELS and SYMBOLS A label consists of one or more characters from the set A-Z, a-z, 0-9. The first character must be alphabetic. There is no limit to the name length. The value the label assumes the range of a 32 bit integer. The label will be set to the current segment counter either before or after a pseudo-op is executed. Most of the time, the label is set before the pseudo-op is executed. The following pseudo-op's labels are created AFTER execution of the pseudo-op: SEG, ALIGN PROCESSOR MODEL The processor model is chosen with the PROCESSOR pseudo-op and should be the first thing you do in your assembly file. Only one PROCESSOR pseudo-op may be declared in the entire assembly. SEGMENTS The SEG pseudo-op creates/sets the current segment. Segments are used to separate the various parts of a program, for example CODE and BSS_DATA; later the linker could place the CODE in the EPROM address range and the data at the ram address range. The use of DS or RMB statements in a segment planned for ROM is not logical. As a result of the use of relocatable segments the ORG statement found in simpler assemblers is not used; its functionality is passed to the linker. 'Uninitialized' (.U) segments do not produce output. Therefore, output generating statements are not allowed in these segments. MULTIPLE SOURCE FILES The pseudo-ops XREF and XDEF make separately assembled source files possible. XREF tells the assembler that a symbol that you will be using is available from another source file. XDEF tells the assembler to make a symbol available to other source files. So, to have a successful reference, one and only one source file must XDEF the symbol and one or more source files must XREF it. Later, when all the component source files have been assembled, the linker takes these deferred references and changes them to specific addresses. There is currently an unnecessary limitation in the use of XREF'd symbols - only one XREF'd symbol may be used per instruction. The example below should be legal but is not legal due to this limitation. XREF stack,stack_size LDS #stack+stack_size-1 The limitation was the easiest way to disallow the similar, but not legal, situations shown in the example below. The current object module format (based on the Amiga format) cannot handle these as no native Amiga assembler can - in fact the SAS assembler 'asm' (5.10b) does not handle the above situation either. XREF stack,stack_size LDS #stack-stack_size-1 LDS #stack+stack_size*4 LDAA #-b I hope to eventually eliminate the un-needed limitation and perhaps some day in the far far future I can eliminate the object format based limitation. There is one more very small limitation. The assembler will report an error for the following code. XREF s LDAA #s-129 It does not know what s will evaluate to and assumes 0 which gives a negative value greater than can be handled in an 8 bit value. If this proves to be a severe hardship to anyone, let me know. MACROS You cannot have a macro definition within a macro definition, but can nest macro calls. Arguments passed to macros are referenced with: {#}. The first argument passed to a macro would thus be {1}. You should always use LOCAL labels (.name) inside macros which you use more than once. {0} represents an EXACT substitution of the ENTIRE argument line. GENERAL ? The other major feature in this assembler is the SUBROUTINE pseudo-op, which logically separates local labels (starting with a dot). This allows you to reuse label names (for example, .1 .fail) rather than think up crazy combinations of the current subroutine to keep it all unique. PSEUDOPS INCLUDE "name" Include another assembly file. [label] SEG[.U] name [label] RSEG[.U] name This sets the current segment, creating it if neccessary. If a .U extension is specified on segment creation, the segment is an UNINITIALIZED or BSS segment. The .U is not needed when going back to an already created uninitialized segment, though it makes the code more readable. The .z force may be used to declare that any symbols declared in this segment may be accessed by direct (page zero) addressing where appropriate. If you need a .U and .z segment, first declare it as .U and then immediately redeclare it as .z. [label] DC[.BWL] exp,exp,exp ... [label] FDB exp,exp,exp ... [label] FCB exp,exp,exp ... [label] FCC exp,exp,exp ... Declare data in the current segment. The default size extension for DC is a byte. FCB allows only byte size and FDB allows only word size. [label] DS[.BWL] exp[,filler] [label] RMB exp[,filler] Declare space (default filler is 0). Note that the number of bytes generated is exp * entrysize (1,2, or 4). The default size extension for DS is a byte. RMB allows only the size of byte. Note that the default filler is always 0. [label] DV[.BWL] eqmlabel exp,exp,exp.... This is equivalent to DC, but each exp in the list is passed through the symbolic expression specified by the EQM label. The expression is held in a special symbol dotdot '..' on each call to the EQM label. See EQM below [label] HEX hh hh hh.. This sets down raw HEX data. Spaces are optional between bytes. NO EXPRESSIONS are allowed. Note that you do NOT place a $ in front of the digits. This is a short form for creating tables compactly. Data is always layed down on a byte-by-byte basis. Example: HEX 1A45 45 13254F 3E12 ERR Abort assembly. [label] XDEF symbol,symbol,symbol [label] PUBLIC symbol,symbol,symbol Defines which symbols/labels are available outside of this module. [label] XREF symbol,symbol,symbol [label] EXTERN symbol,symbol,symbol Declares which symbols/labels from outside modules are used in this module. The .z force may be used to declare that the symbols may be accessed by direct (page zero) addressing where appropriate. PROCESSOR model Do not quote. Model is one of: 6803,HD6303,68705,68HC11, 68HC16. Can only be executed once, and should be the first thing encountered by the assembler. ECHO exp,exp,exp The expressions (which may also be strings), are echod on the screen and into the list file [label] ALIGN N[,fill] Align the current PC to an N byte boundry. The default fill character is always 0. [label] SUBROUTINE name This isn't really a subroutine, but a boundry between sets of temporary labels (which begin with a dot). Temporary label names are unique within segments of code bounded by SUBROUTINE: CHARLIE subroutine ldx #10 .1 dex bne .1 BEN subroutine ldx #20 .qq dex bne .qq Automatic temporary label boundries occur for each macro level. Usually temporary labels are used in macros and within actual subroutines (so you don't have to think up a thousand different names) symbol EQU exp The expression is evaluated and the result assigned to the symbol. symbol EQM exp The STRING representing the expression is assigned to the symbol. Occurances of the symbol in later expressions causes the string to be evaluated for each occurance. Also used in conjuction with the DV psuedo-op. symbol SET exp Same as EQU, but the symbol may be reassigned later. END [symbol] Optional. If used with a symbol name the value of that symbol will be entered into the output file as the starting address of the program. May only be used once and only at the end of the file. Be careful - if a symbol is not given and a comment without a preceding ';' is used the first word of the comment will be interpreted as the symbol. MAC name MACRO name Declare a macro. lines between MAC and ENDM are the macro. You cannot recursively declare a macro. You CAN recursively use a macro (reference a macro in a macro). No label is allowed to the left of MAC or ENDM. ENDM End of macro def. NO LABEL ALLOWED ON THE LEFT! MEXIT Used in conjuction with conditionals. Exits the current macro level. [label] IFCONST exp [label] IFD exp Is TRUE if the expression result is defined, FALSE otherwise and NO error is generated if the expression is undefined. [label] IFNCONST exp [label] IFND exp Is TRUE if the expression result is undefined, FALSE otherwise and NO error is generated if the expression is undefined. [label] IF exp Is TRUE if the expression result is defined AND non-zero. Is FALSE if the expression result is defined AND zero. Neither IF or ELSE will be executed if the expression result is undefined. If the expression is undefined, another assembly pass maybe required. [label] ELSE ELSE the current IF. [label] ENDIF [label] ENDC [label] EIF Terminate an IF. ENDIF and EIF are equivalent. [label] REPEAT exp [label] REPEND Repeat code between REPEAT/REPEND 'exp' times. if exp == 0, the code repeats forever. exp is evaluated once. Y SET 0 REPEAT 10 X SET 0 REPEAT 10 DC X,Y X SET X + 1 REPEND Y SET Y + 1 REPEND generates an output table: 0,0 1,0 2,0 ... 9,0 0,1 1,1 2,1... 9,1, etc... Labels within a REPEAT/REPEND should be temporary labels with a SUBROUTINE pseudoop to keep them unique. The Label to the left of REPEND is assigned AFTER the loop FINISHES. FORCED ADDRESSING MODES [label] XXX[.force] operand XXX is some mnemonic, not necessarily three characters long. The .FORCE optional extension is used to force specific addressing modes. Force extensions are also used with DS,DC, and DV to determine the element size. example: lda.z charlie Force Description Alternate Force Extension i implied ind indirect word 0 implied b byte address z d (zeropage, direct) bx byte address indexed x by byte address indexed y w word address e a (extended, absolute) l longword (4 bytes) (DS/DC/DV) r relative u uninitialized (SEG) EXPRESSIONS Some operators, such as ||, can return a resolved value even if one of the expressions is not resolved. Operators are as follows: NOTE WELL! Some operations will result in non-byte values when a byte value was wanted. Example: ~1 is NOT $FF, but $FFFFFFFF. Preceding it with a < (take LSB of) will solve the problem. ALL ARITHMETIC IS CARRIED OUT IN 32 BITS. The final result will be automatically truncated to the maximum handleable by the particular machine language (usually a word) when applied to standard mnemonics. PRECEDENCE UNARY 20 ~exp one's complement. 20 -exp negation 20 !exp not expression (returns 0 if exp non-zero, 1 if exp zero) 20 exp take MSB byte of an expression BINARY 19 * multiplication 19 / division 19 % mod 18 + addition 18 - subtraction 17 >>,<< shift right, shift left 16 >,>= greater, greater equal 16 <,<= smaller, smaller equal 15 == equal to. Try to use this instead of = 15 = exactly the same as == (exists compatibility) 15 != not equal to 14 & logical and 13 ^ logical xor 12 | logical or 11 && left expression is true AND right expression is true 10 || left expression is true OR right expression is true 9 ? if left expression is true, result is right expression, else result is 0. [10 ? 20] returns 20 8 [] group expressions 7 , separate expressions in list (also used in addressing mode resolution, BE CAREFUL!  CONSTANTS nnn decimal  0nnn octal  %nnn binary  $nnn hex  'c character  'c' character  "cc.." string (NOT zero terminated if in DC/DS/DV)  [exp]d the constant expressions is evaluated and it's decimal result turned into an ascii string. SYMBOLS .. holds evaluated value in DV pseudo op .name represents a temporary symbol name. Temporary symbols may be reused inside MACROS and between SUBROUTINES, but may not be referenced across macros or across SUBROUTINEs. . current program counter (as of the beginning of the instruction). name beginning with an alpha character and containing letters, numbers, or '_'. Represents some global symbol name. WHY codes: Each bit in the WHY word (verbose option 1) is a reason (why the assembler needs to do another pass), as follows: Bit Meaning 0 expression in mnemonic not resolved 1 2 expression in a DC not resolved 3 expression in a DV not resolved (probably in DV's EQM symbol) 4 expression in a DV not resolved (could be in DV's EQM symbol) 5 expression in a DS not resolved 6 expression in an ALIGN not resolved 7 8 ???ALIGN: Normal origin not known (if in ORG at the time) 9 EQU: expression not resolved 10 EQU: value mismatch from previous pass (phase error) 11 IF: expression not resolved 12 REPEAT: expression not resolved 13 a program label has been defined after it has been referenced (forward reference) and thus we need another pass 14 a program label's value is different from that of the previous pass (phase error) Certain errors will cause the assembly to abort immediately, others will wait until the current pass is over. The remaining allow another pass to occur in the hopes the error will fix itself. HIGH LEVEL CONSTRUCTS The assembler allows for some high level C-like constructs that help to make your assembler source file self documenting and clearer. The expressions allowed in these constructs are quite different, check the documentation below. [label] _IF exp If the expression (condition) evaluates to true then the statements following this statement and including up to the associated _ELSE or _ENDIF statement are executed. _ELSE marks then end of the true condition portion of the _IF block and the start of the false condition portion _ENDIF marks the end of an _IF block [label] _FOR [exp]\\exp\\exp The optional first expression (assignment) is executed and then the second expression (condition) is evaluated. As long as it evaluates to true, the statements following this statement and including up to the associated _NEXT statement will be executed. Each time the _NEXT statement is reached the third expression (assignment) is executed and then the second expression is re-evaluated. _NEXT marks the end of a _FOR block If an _IF, _ELSE, _FOR or _NEXT statement causes an branch address range error you can instruct that extended addressing be used with the .w force. There are currently two types of expression: condition and assignment. Each consists of three parts and the parts must appear in the defined order. := [!] | [!] := := := <|<=|==|!=|>|>=|.HI.|.LO.|.HS.|.LS. := |