URL
https://opencores.org/ocsvn/light8080/light8080/trunk
Subversion Repositories light8080
[/] [light8080/] [trunk/] [tools/] [c80/] [AS80.txt] - Rev 73
Go to most recent revision | Compare with Previous | Blame | View Log
Kingswood Software Development Tools AS80-------------------------------------------------------------------------NAMEas80 - assembler for 8080, 8085 and Z80 microprocessors.SYNOPSISas80 [-cdghilnopqstvwxz] fileDESCRIPTIONThis documentation is for as80 [1.10].Copyright 1990-1994, Frank A. Vorstenbosch, Kingswood Software.AS80 is an assembler for the Intel 8080/8085 and Zilog Z80microprocessors. It reads input from an ASCII text file, assemblesthis into memory, and then writes a listing and a binary or hex file.AS80 is case sensitive, not only does it differentiate between thelabels XYZ and xyz, but it also requires all (pseudo) instruction andregister names to be lower case. This way, the listing is the mostreadable. Option -i can be used to make the assembler case insensitive.Alternatively, the included TOLOWER program can be used to convertsources to lower case.OPTIONSAs80 recognizes the following options:-c Show number of cycles per instruction in listing. Thisdecreases the number of columns available for listing by 5.The number of cycles is printed between brackets [ and ].-d<name>Define a label before the first source line is read. Ifno name is specified, DEBUG is defined. The label isEQUated to be 1.-g Generate source-level debug information file. This filecan then be used in in-system debugging or a softwaresimulator.-h<lines>Specify height of page for listing. This option determinesthe number of lines per printed page. Each page has a headerand is terminated by a form-feed character. The specialcase -h0 indicates an infinite page length. In this case,page breaks are only inserted between the two passes andthe symbol table (if present).-i Ignore case in opcodes. In this way, the assembler does notdifferentiate between 'add' and 'ADD', for example. Labelsare still case sensitive.-l Generate pass 2 listing.-l<filename>Listing file name. The listing file is used for pass 1 andpass 2 listing, for the symbol table (printed between thetwo passes), and some statistics. When neither -p nor -tis specified, and -l<filename> is given, then the assemblerautomatically generates a pass 2 listing. When -p or -t isspecified, an additional -l should be given is a pass 2listing is required. The filename - can be used to directthe listing to standard output.-l Generate pass 2 listing.-m Show macro expansions in listing. Macro lines are prefixedby a > sign.-n Disable optimizations. When this option is specified nooptimizations will be done, even when the OPT pseudo-instruction is used in the source code.-o<filename>Specify binary or s-records output file name. The assemblerautomatically adds ".bin" for binary output or ".s19" fors-records output when no extension is given.-p Generate pass 1 listing. This may be used to examine anyoptimizations/bugs generated in pass 2.-q Quiet mode. No running line counter is displayed on standarderror output.-s Write s-records instead of binary file. The s-records filecontains data for (only) the used memory; the binary filebegins at the lowest used address, and continues up to thehighest used address; filling unused memory between thesetwo addresses with either $ff or $00.-s2 Write intel-hex file instead of binary file. The intel-hexfile contains data for (only) the used memory.-t Generate symbol table. The symbol table is listed betweenpasses one and two, displaying the name, hexadecimal anddecimal value of each label, using 4-digit hexadecimalnumbers where possible, otherwise 8-digit numbers. Thedecimal value is followed by an asterisk if the label isredefinable (defined using SET instead of EQU).-v Verbose mode. More information is displayed on standardoutput.-w<width>Specify column width. Normally, the listing is printed using79 columns for output to a 80-column screen or printer. Ifthe -w option is given without a number following it, thenthe listing will be 131 columns wide, otherwise it will bethe number of colulmns specified (between 60 and 200).-x1 Use 8085 extensions. The 8085 CPU has two additionalinstructions and different cycle counts, but is otherwisesoftware compatible to the 8080. When this option is notspecified the assembler rejects the RIM and SIM instructions.-x or-x2Use Z80 extensions. The Z80 has many additional instructionsand addressing modes, but is otherwise software compatible tothe 8080. When this option is not specified the assemblerrejects all Z80 new instructions and addressing modes.-x3 Use Z80 extensions and index register byte instructions.The IX and IY registers were originally intended to besplit in IXH/IXL and IYH/IYL register pairs. For somereason (bug in original mask set?) these instructions werenot included by Zilog in the programming manuals, butthey do work on all CPUs I've seen. Your mileage may vary.Note that these extensions do NOT work on the Z180/181 andH64180, but they DO (and are documented) on the Z280.-z Fill unused memory with zeros. Normally when a binary fileis generated, unused bytes between the lowest and highestused addresses are filled with $ff, the unprogrammed stateof EPROMs. If this is not wanted, the -z option can be usedto initialize this memory to $00. With s-records, unusedmemory is not output to the file, and this option forces thecreation of an S9 (start address) record instead, even if nostart address is specified in the file with the END pseudo-instruction.Commandline options can be catenated, but no other option can followone that may have a parameter. Thus:-tlfileis correct (specifying symbol table and pass 2 listing), but-h5tis not.It is possible to discard any of the the output files by specifyingthe name 'nul'.EXPRESSIONSThe assembler recognizes most C-language expressions. The operatorsare listed here in order of precedence, highest first:() braces to group subexpressions* $ current location counterunary + - ! ~ unary + (no-operation), negation, logical NOT,binary NOT* / % multiplication, division, modulo+ - addition, subtraction<< >> shift left, shift right< > <= >= comparison for greater/less than= != comparison for equality (== can be used for =)& binary AND^ binary XOR| binary OR&& logical AND|| logical ORhi lo high byte, low byteThe logical NOT (!) evaluates to zero if the parameter is nonzero,and vice versa. The binary NOT (~) complements all the bits in itsparameter. Logical AND (&&) and OR (||) operators evaluate to oneif both resp. at least one argument is nonzero. These two operatorsevaluate both arguments, unlike the C-language versions.Note: the asterisk is both used as the multiplication operator, andas symbol for the current location. The assembler determines fromthe context which is which. Thus:5**is a valid expression, evaluating to five times the current locationcounter, and:2+*/2is too, evaluating to the current location counter divided by two, towhich two is added. In the same way, the % sign is both used as themodulo operator and the prefix for binary numbers.Numbers can be specified in any number base between 2 and 36.Decimal numbers can be used without a prefix, hexadecimal numberscan be prefixed by $, octal numbers by @, and binary numbers by %.Other number bases can be used by using the following format:<base>#<number>,where the base is the number base to use (must be specified indecimal), and number is the value. Thus:1000 - decimal number, value 10*10*10=1000%1000 - binary number, value 2*2*2=8@1000 - octal number, value 8*8*8=512$1000 - hexadecimal number, value 16*16*16=4096#1000 - hexadecimal number, value 16*16*16=40960b1000 - binary number, value 2*2*2=80x1000 - hexadecimal number, value 16*16*16=40962#1000 - binary number, value 2*2*2=84#1000 - base-4 number, value 4*4*4=647#1000 - base-7 number, value 7*7*7=34336#1000 - base-36 number, value 36*36*36=444528For number bases greater than 10, additional digits are representedby letters, starting from A. Both lower and upper case letters canbe used.11#aa = 12016#ff = 25525#oo = 62436#zz = 1295PSEUDO-INSTRUCTIONSalign <expression>Align fills zero or more bytes with zeros until the new addressmodulo <expression> equals zero. If the expression is not present,align fills zero or one bytes with zeros until the new addressis even.Example 1:align 256 ; continue assembly on the; next 256-byte pageExample 2:align ; make sure table beginsTable dw 1,2,3 ; on an even addressbssPut all following data in the bss segment. Only data pseudo-instructionscan be used in the bss segment, and these only increment the locationcounter. It is up to the programmer to initialize the bss segment. Thebss segment is especially meaningful in a ROM based system wherevariables must be placed in RAM, and RAM is not automatically initialized.The assembler internally maintains three separate location counters,one for the code segment, one for the data segment and one for theuninitialized data segment. The user is responsible for not overlappingthe segments by setting appropriate origins. The code, data and bsspseudo-instructions can be used to interleave code and data in the sourcelisting, while separating the three in the generated program. Theassembler starts with the code segment if none is specified.Example:codeorg $f000 ; Assuming 4 kbyte code ROMdata ; with 2 kbyte program andorg $f800 ; 2 kbyte initialized databssorg 0 ; bss segment is in RAMBuffer ds 100codeBegin ld hl,Tableld de,Bufferld bc,3ldir...dataTable db 1,2,3codeMyFunc ld ix,Table..codePut all following assembled instructions and data in the code segment.See BSS.dataPut all following assembled instructions and data in the data segment.See BSS.db <bytelist>Define bytes. The bytes may be specified as expressions or strings,and are placed in the current (code or data) segment. This pseudoinstruction is similar to the Zilog-defined defb and defm pseudo-instructions.Example:Message db "\aError\r\n",0defb <bytelist>Define bytes. The bytes may be specified only as expressions,and are placed in the current (code or data) segment. Thispseudo-instruction is similar to the db pseudo-instruction.Example:Message defb 7defm "Error"defb 13,10,0defm <string>Define message. The bytes may be specified only as a string, andare placed in the current (code or data) segment. This pseudo-instruction is similar to the db pseudo-instruction.ds <expression>defs <expression>Define zero or more bytes empty space. The specified number ofbytes are filled with zeros. This pseudo-instruction is identicalto the Zilog-defined pseudo-instruction defs.Example:ds 100 ; reserve 100 bytes heredw <wordlist>defw <wordlist>Define words. The words are placed in the current (code or data)segment. This pseudo-instruction is identical to the Zilog-defined defw pseudo-instruction.Example:ld a,2*Function ; number of functionld hl,JumpTableadd a,l ; calculate HL+Ald l,aadc a,hsub lld h,ajp (hl) ; jump to functionJumpTable dw Function0dw Function1dw Function2elseThe else pseudo-instruction can be used for if-then-elseconstructions. It must be placed between an if and an endifinstruction. For an example, see the if pseudo-instruction.end <expression>The end pseudo-instruction is optional, and need not be used. Ifit is used, its optional operand specifies the staring address ofthe program. This address is displayed when the program isassembled, and is also placed in the s-record output file.Example:end StartendifThe endif pseudo-instruction must be used to close an if-endifor if-else-endif construction. For an example, see the ifpseudo-instruction.<label> equ <expression>The equ (equate) pseudo-instruction sets the specified label tothe value of the expression. The label may not already exist.Some programmers choose to use only upper-case identifiers forlabels defined in this way to differentiate them from addresses.Example:ESCAPE equ 27if <expression>The if pseudo-instruction can be used in conjunction with theendif and possibly the else pseudo-instructions to selectivelyenable and disable pieces of code in the source. If the expressiongiven evaluates to zero, then the following code up to the matchingelse or endif is not included in the assembly. If the expressionis nonzero, then the following code is included, but any codebetween the matching else and endif is not.The original Zilog assemblers called this pseudo-instruction COND.Example:if COUNT=2 | COUNT=4add a,a ; shift left for countsif COUNT=4 ; of 2 and 4add a,aendifelseld b,COUNT ; otherwise use slow multiplycall Multiplyendifinclude <string>The named file is included in the assembly at this point. Afterit has been read, assembly continues with the next line of thecurrent file. Include files may be nested.Example:include "z180.i"listEnable generation of the listing in the list-file. If the listinghas been disabled twice, it must be enabled twice before it isgenerated. When no -p or -l option has been specified on thecommand line, this pseudo-instruction has no effect.macroDefine a macro. Macros allow a block of source statements to begiven a name, and then that name can be used to include thestatements anywhere in the program. Parameters can be used topass arguments to the macro. In the macro definition namescan be used to respresent the arguments; these names in the textare substituted with the value passed on macro expansion.Macro arguments can also be represented by using \1 through \9in the macro text; these sequences are replaced by the firstthrough ninth argument respectively. The special value \0contains the number of arguments passed to the macro.Example 1:Macro1 macro text,valuedw valuedb text,0db "value=",'value',0endmMacro2 macrodw \2db \1,0db "value=\2",0endmMacro1 "Hello",123Macro2 "Hello",123Macros can also use local labels, for when a unique label is neededeach time the macro is expanded. This can be used when the macrocontains a conditional jump, or a loop of some kind, or simply needsto reference some data. Local labels can be declared by using thelocal pseudo-instruction, or by using the \? special value. The\? value is replaced by a unique four-digit decimal number eachtime a macro is used.Example 2:Macro3 macro textlocal Stringcodedw StringdataString db text,0endmMacro4 macro textcodedw String\?dataString\? db text,0endmMacro3 "Hello"Macro4 "Hello"Macros can also contain if...endif statements, and the exitmpseudo-instruction can be used to terminate macro expansion.Macros can also call other macros (or themselves) up to a nestingdepth of 15 levels.Macro5 macro countif count>25exitmendifdb 10*countendmMacro5 10Macro5 100nolistDisable generation of the listing in the list-file.nooptDisable optimizations. If the -n option has been specified on thecommand line, this pseudo-instruction has no effect.nop <expression>No operation. When the optional expression is not present, thisis simply the nop instruction of the processor. When theexpression is present, the specified number of nop instructionsare inserted.Example:nop 10optEnable optimizations. If the -n option has been specified on thecommand line, this pseudo-instruction has no effect.When optimization is enabled, the assembler tries to use theshortest and fastest instructions possible which have the effectthe user wants. It may replace any extended-address instructionby direct-address instructions (provided the direct pseudo-instruction has been used). It replaces long branches with jumpsor short branches, calls with branches to subroutines, andreplaces zero-offset indexed instructions by no-offset indexedinstructions. The effects of optimizations is clearly visible ifboth a pass one and a pass two listing is generated.org <expression>The org (origin) pseudo-instruction specifies the next address tobe used for assembly. When no origin has been specified, theassembler uses the value 0. The assembler maintains three separatelocation counters: one for the code segment, one for the datasegment, and one for the bss segment. See the code and pseudo-instruction for more information.page <expression>When the optional expression is not present, the assembly listingis continued on the next page. When the expression is present,the listing is continued on the next page only if the specifiednumber of lines do not fit on the current page.<label> set <expression><label> = <expression>The set pseudo-instruction sets the specified label to the valueof the expression. The label may or may not already exist.Some programmers choose to use only upper-case identifiers forlabels defined in this way to differentiate them from addresses.Example:CURRENT set 0...CURRENT set CURRENT+1struct <name>struct <name>,<expression>The struct (structure) pseudo-instruction can be used to definedata structures in memory more easily.The name of the structure is set to the total size of the structure;if the expression is present, the starting offset is the value ofthe expression in stead of zero.Between the struct and end struct pseudo-instructions the followingpseudo-instructions can be used: db, dw, ds, label, align.Within structures these pseudo-instructions take a slightly differentformat than normally:db <name> element is one bytedw <name> element is two bytesds <name>,<expression> element is the specified number of bytesds <expression> skip the specified number of byteslabel <name> element is zero bytes, i.e. set the nameto the current structure offsetalign <expression> skip until (offset%expression)=0align skip until offset is evenExample:struct ListNode,4dw LN_Nextdw LN_Previousdb LN_Typealignlabel LN_Simple ; size of structure so faralign 8ds LN_Data,10end structThis is identical to:LN_Next equ 4 ;\LN_Previous equ 6 ; offset of structure elementsLN_Type equ 8 ;/LN_Simple equ 10 ; size of structure so farLN_Data equ 16 ; offset of structure elementListNode equ 26 ; size of structuretitle <string>The title pseudo-instruction sets the title to be used in theheader of each listing page. The string should be no longer than80 characters.Example:title "DIS80 : A disassembler for a 8080 CPU"ADDRESSING MODESThe assembler allows all 8080 (and when enabled also Z80) addressingmodes. The use of an expression between braces as an address disallowsbraces at the outermost level for immediate values. The assembleris capable to determine thatld a,(10)+1andld a,1+(10)are immediate operands. You can also use rectangular brackets[ and ] to include an address.List of available modes:immediate(address)(bc) (de) (hl) (sp)Additional addressing modes for the Z80 and Z180:(ix+offset) (ix-offset)(iy+offset) (iy-offset)(c)LIST OF ACCEPTED INSTRUCTIONSadc add align and bit bss call ccf code cp cpd cpdr cpi cpir cpl daadata db dd dec defb defm defs defw di disable djnz ds dw ei else enableend endif equ ex exx fcb fcc fcw fdb halt if im in inc include ind indrini inir jp jr ld ldd lddr ldi ldir list neg nolist noopt nop opt ororg otdr otir out outd outi page pop push res ret reti retn rim rl rlarlc rlca rld rmb rr rra rrc rrca rrd rst sbc scf set shl shr sim sl slasr sra srl stc struct sub title tsti xorOf these instructions, the following are (more or less) synonymous,and can be used interchangably.YOU CAN USE WHERE YOU WOULD PREVIOUSLY USEnop 6 - nop nop nop ....push bc,de - push bc ; push depop bc,de - pop de ; pop bc (note reversed order)disable - dienable - eisr - srlshr - srlsl - slashl - slastc - scfld bc,de - ld b,d ; ld c,eld ix,bc - ld xh,b ; ld xl,cadd R - add a,Ror a,R - or Rin (c) - tsti (c)ex hl,de - ex de,hldjnz LBL - dec b ; jp nz,LBLjp nv,LBL - jp pe,LBL (no overflow/parity even)jp v,LBL - jp po,LBL (overflow/parity odd)jp ns,LBL - jp p,LBL (no sign/positive)jp s,LBL - jp m,LBL (sign/negative)Operands:xh - ixhxl - ixlyh - iyhyl - iyl[Address] - (Address)[hl] - (hl)(ix-6) - (ix+-6)And pseudo-instructions:db - defb, defmdw - defwds - defs= - setstruct - lots of EQUsLIST OF OTHER KEYWORDS! != $ % & && ( ) * + , - / < << <= = > >= >> [ ] ^ | || ~a af af' align b bc c d db de ds dw e end h hl i ix ixh ixl iy iyhiyl l label m nc ns nv nz p pe po r s sp struct v xh xl yh yl zFILES<file>.a80 - source file.<file>.z80 - source file -- first alternative.<file>.asm - source file -- second alternative.<file>.lst - List file.<file>.s19 - Motorola S-records output file.<file>.hex - Intel hex output file.<file>.bin - Binary output file.BUGSNo provision for linking other pre-assembled modules is made.Escape sequences in strings can't use the \x<digits> and\<digits> formats.RETURNSAs80 returns one of the following values:0 - Source file assembled without errors.1 - Incorrect parameter specified on the commandline.2 - Unable to open input or output file.3 - Assembly gave errors.4 - No memory could be allocated.DIAGNOSTICSHelp message if only parameter is a question mark, or if anillegal option has been specified.AUTHORThis is copyrighted software, but may be distributed freely as longas this document accompanies the assembler, and no copyright messagesare removed. You are explicitly NOT allowed to sell this softwarefor anything more than a reasonable copying fee, say US$5.To contact the author:Frank A. VorstenboschKingswood SoftwareP.O. Box 85800 Phone: +31-(70)-355 52412508CM The Hague BBS: +31-(70)-355 8674Netherlands Email: falstaff@xs4all.nl-------------------------------------------------------------------------
Go to most recent revision | Compare with Previous | Blame | View Log
