Manaul ASXX
Manaul ASXX
ASxxxx Assemblers
and
Version 2.0
August 1998
Page 2
P R E F A C E
Alan R. Baldwin
Kent State University
http://shop−pdp.kent.edu/ashtml/asxxxx.htm
baldwin@shop−pdp.kent.edu
tel: (330) 672 2531
fax: (330) 672 2959
Page 3
C O N T R I B U T O R S
Marko Makela
Sillitie 10 A
01480 Vantaa
Finland
Internet: Marko.Makela@Helsinki.Fi
EARN/BitNet: msmakela@finuh
John L. Hartman
jhartman@compuserve.com
http://ourworld.compuserve.com/homepages/jhartman/
G. Osborn
gary@s−4.com
Page 4
Source Langauge: C
Abstract:
Page ii
Page iii
Page iv
Page v
CHAPTER 1
THE ASSEMBLER
The label and comment fields are optional. The operator and
operand fields are interdependent. The operator field may be an
assembler directive or an assembly mnemonic. The operand field
may be optional or required as defined in the context of the
operator.
abcd: nop
More than one label may appear within a single label field.
Each label so specified is assigned the same address value. For
example, if the value of the current location counter is
1FF0(H), the multiple labels in the following statement are each
assigned the value 1FF0(H):
abcd:
aq:
$abc: nop
abcd:: nop
A through Z
a through z
The label must not start with the characters 0−9, as this
designates a local symbol with special attributes described in a
later section.
The label must not start with the sequence $$, as this
represents the temporary radix 16 for constants.
the tab between lda and abcd terminates the operator field and
defines the beginning of the operand field; a comma separates
the operands abcd and x; and a semicolon terminates the operand
field and defines the beginning of the comment field. When no
comment field follows, the operand field is terminated by the
end of the source line.
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
1$
27$
138$
244$
ALPHA = EXPRESSION
Note that the range of a local symbol block may extend across
program areas.
The use of the same local symbol within a local symbol block
The period (.) is the symbol for the current location coun−
ter. When used in the operand field of an instruction, the
period represents the address of the first byte of the
instruction:
QK = 0
. = . + expression
1.3.5 Numbers
1.3.6 Terms
1. A number.
2. A symbol:
1. A period (.) specified in an expression causes the
current location counter to be used.
2. A User−defined symbol.
3. An undefined symbol is assigned a value of zero and
inserted in the User−Defined symbol table as an un−
defined symbol.
1.3.7 Expressions
* / % multiplication,
division, and
modulus first.
+ − addition and
subtraction second.
^ exclusive or fourth.
| logical or last
Format:
.module string
Format:
.title string
Format:
.sbttl string
Format:
.page
Format:
Format:
Format:
The .blkb and .ds directives reserve byte blocks in the ob−
ject module; the .blkw directive reserves word blocks.
Format:
.ascii /string/
The .ascii directive places one binary byte of data for each
character in the string into the object module.
Format:
.ascis /string/
The .ascis directive places one binary byte of data for each
character in the string into the object module. The last
character in the string will have the high order bit set.
Format:
.asciz /string/
The .asciz directive places one binary byte of data for each
character in the string into the object module. Following all
the character data a zero byte is inserted to terminate the
character string.
Format:
.radix character
B,b Binary
O,o Octal
Q,q
D,d Decimal
'blank'
H,h Hexidecimal
X,x
Format:
.even
.odd
Format:
Format:
.org exp
Format:
.globl sym1,sym2,...,symn
J == expression or J::
Format:
.if expr
. ;}
. ;} range of true condition
. ;}
.else
. ;}
. ;} range of false condition
. ;}
.endif
.if 0
.page
This text will be bypassed during assembly
but appear in the listing file.
.
.
.
.endif
Format:
.include string
Format:
The set direct page directive has a common format in all the
AS68xx assemblers. The .setdp directive is used to inform the
assembler of the current direct page region and the offset ad−
dress within the selected area. The normal invocation methods
are:
or
.setdp 0,DIRECT
for all the 68xx microprocessors (the 6804 has only the paged
ram area). The commands specify that the direct page is in area
DIRECT and its offset address is 0 (the only valid value for all
but the 6809 microprocessor). Be sure to place the DIRECT area
at address 0 during linking. When the base address and area are
not specified, then zero and the current area are the defaults.
If a .setdp directive is not issued the assembler defaults the
direct page to the area "_CODE" at offset 0.
At link time specify the base and global equates to locate the
direct page:
−b DIRECT = 0x1000
−g DIRECT = 0x1000
Both the area address and offset value must be specified (area
and variable names are independent). The linker will verify
that the relocated direct page accesses are within the direct
page.
The preceeding sequence could be repeated for multiple paged
areas, however an alternate method is to define a non−paged area
and use the .setdp directive to specify the offset value:
d decimal listing
q octal listing
x hex listing (default)
The file name for the .lst, .rel, and .sym files is the first
file name specified in the command line. All output files are
ascii text files which may be edited, copied, etc. The output
files are the concatenation of all the input files, if files are
to be assembled independently invoke the assembler for each
file.
1.6 ERRORS
where * is the error code, nnn is the line number, and filename
is the source/include file.
4. Blank line
5. Source text
The error field may contain upto 2 error flags indicating any
errors encountered while assembling this line of source code.
1. * paged relocation
[XDQ][HL]
X Hexidecimal radix
D Decimal radix
Q Octal radix
H Header
M Module
A Area
S Symbol
T Object code
CHAPTER 2
THE LINKER
The linker may run in the command line mode or command file
modes. The allowed startup linker commands are:
ASLINK −[cfpn]
ASLINK
argv: −[cfpn]
[XDQ][HL]
X Hexidecimal radix
H Header
M Module
A Area
S Symbol
T Object code
R Relocation information
P Paging information
M name
The module line specifies the module name from which this
header segment was assembled. The module line will not appear
if the .module directive was not used in the source program.
S string Defnnnn
or
S string Refnnnn
The area line defines the area label, the size (ss) of the
area in bytes, and the area flags (ff). The area flags specify
the ABS, REL, CON, OVR, and PAG parameters:
2.5.6 T Line
T xx xx nn nn nn nn nn ...
2.5.7 R Line
R 0 0 nn nn n1 n2 xx xx ...
The groups of 4 bytes are repeated for each item requiring relo−
cation in the preceeding T line.
2.5.8 P Line
P 0 0 nn nn n1 n2 xx xx
and/or
During Pass two the linker reads the T, R, and P lines per−
forming the necessary relocations and outputting the absolute
code. Various errors may be reported during this process
The P line processing can produce only one possible error:
The error message specifies the file and module where the .setdp
direct was issued and indicates the page area and the page
These error messages specify the file, module, area, and offset
within the area of the code referencing (Refby) and defining
(Defin) the symbol. If the symbol is defined in the same module
as the reference the linker is unable to report the symbol name.
The assembler listing file(s) should be examined at the offset
from the specified area to located the offending code.
CHAPTER 3
1. M6809.H
2. M09EXT.C
3. M09MCH.C
4. M09ADR.C
5. M09PST.C
6. ASXXXX.H
7. ASMAIN.C
8. ASLEX.C
9. ASSYM.C
10. ASSUBR.C
11. ASEXPR.C
12. ASDATA.C
13. ASLIST.C
14. ASOUT.C
The first five files are the 6809 processor dependent sec−
tions which contain the following:
1. ASLINK.H
2. LKMAIN.C
3. LKLEX.C
4. LKAREA.C
5. LKHEAD.C
6. LKSYM.C
7. LKEVAL.C
8. LKDATA.C
9. LKLIST.C
10. LKRLOC.C
11. LKLIBR.C
12. LKS19.C
13. LKIHX.C
APPENDIX A
AS6800 ASSEMBLER
The terms data, dir, offset, ext, and label may all be expres−
sions.
Note that not all addressing modes are valid with every in−
struction, refer to the 6800 technical data for valid modes.
aba cba
clc cli
clv daa
des dex
ins inx
nop rti
rts sba
sec sei
sev swi
tab tap
tba tpa
tsx txs
wai
psha pshb
psh a psh b
pula pulb
pul a pul b
asla aslb
asl a asl b
asl []
asra asrb
asr a asr b
asr []
clra clrb
clr a clr b
clr []
coma comb
com a com b
com []
deca decb
dec a dec b
dec []
inca incb
inc a inc b
inc []
lsla lslb
lsl a lsl b
lsl []
lsra lsrb
lsr a lsr b
lsr []
nega negb
neg a neg b
neg []
rola rolb
rol a rol b
rol []
rora rorb
ror a ror b
ror []
tsta tstb
tst a tst b
tst []
adca [] adcb []
adc a [] adc b []
adda [] addb []
add a [] add b []
anda [] andb []
and a [] and b []
bita [] bitb []
bit a [] bit b []
cmpa [] cmpb []
cmp a [] cmp b []
eora [] eorb []
eor a [] eor b []
ldaa [] ldab []
lda a [] lda b []
oraa [] orab []
ora a [] ora b []
sbca [] sbcb []
sbc a [] sbc b []
staa [] stab []
sta a [] sta b []
suba [] subb []
sub a [] sub b []
jmp [] jsr []
cpx []
lds [] sts []
ldx [] stx []
APPENDIX B
AS6801 ASSEMBLER
Format:
.hd6303
The terms data, dir, offset, ext, and label may all be expres−
sions.
Note that not all addressing modes are valid with every in−
struction, refer to the 6801/6303 technical data for valid
aba abx
cba clc
cli clv
daa des
dex ins
inx mul
nop rti
rts sba
sec sei
sev swi
tab tap
tba tpa
tsx txs
wai
asra asrb
asr a asr b
asr []
clra clrb
clr a clr b
clr []
coma comb
com a com b
com []
deca decb
dec a dec b
dec []
eora eorb
inca incb
inc a inc b
inc []
nega negb
neg a neg b
neg []
rola rolb
rol a rol b
rol []
rora rorb
ror a ror b
ror []
tsta tstb
tst a tst b
tst []
adca [] adcb []
adc a [] adc b []
anda [] andb []
and a [] and b []
bita [] bitb []
bit a [] bit b []
cmpa [] cmpb []
cmp a [] cmp b []
ldaa [] ldab []
oraa [] orab []
ora a [] ora b []
sbca [] sbcb []
sbc a [] sbc b []
staa [] stab []
sta a [] sta b []
jmp [] jsr []
cpx [] ldd []
lds [] ldx []
std [] sts []
stx []
xgdx slp
APPENDIX C
AS6804 ASSEMBLER
The terms data, dir, and ext may be expressions. The label for
the short branchs beq, bne, bcc, and bcs must not be external.
Note that not all addressing modes are valid with every in−
struction, refer to the 6804 technical data for valid modes.
coma decx
decy incx
incy rola
rti rts
stop tax
tay txa
tya wait
add []
and []
jsr []
jmp []
brclr #data,[],label
brset #data,[],label
bclr #label,[]
bset #label,[]
mvi [],#data
asla
bam label
bap label
bxmi label
bxpl label
bymi label
bypl label
clra
clrx
clry
deca
decx
decy
inca
incx
incy
ldxi #data
ldyi #data
nop
tax
tay
txa
tya
APPENDIX D
AS6805 ASSEMBLER
a − 8−bit accumulator
x − index register
The terms data, dir, offset, and ext may all be expressions.
Note that not all addressing modes are valid with every in−
struction, refer to the 6805 technical data for valid modes.
clc cli
nop rsp
rti rts
sec sei
stop swi
tax txa
wait
brset #data,*dir,label
brclr #data,*dir,label
bset #data,*dir
bclr #data,*dir
nega negx
neg []
coma comx
com []
lsra lsrx
lsr []
rora rorx
ror []
asra asrx
asr []
lsla lslx
lsl []
deca decx
dec []
inca incx
inc []
tsta tstx
tst []
clra clrx
clr []
sub [] cmp []
sbc [] cpx []
and [] bit []
lda [] sta []
eor [] adc []
ora [] add []
ldx [] stx []
jmp [] jsr []
APPENDIX E
AS6808 ASSEMBLER
a − 8−bit accumulator
The terms data, dir, offset, and ext may all be expressions.
Note that not all addressing modes are valid with every in−
struction, refer to the 68HC08 technical data for valid modes.
brset #data,*dir,label
brclr #data,*dir,label
bset #data,*dir
bclr #data,*dir
cbeqa [],label
cbeqx [],label
cbeq [],label
dbnza label
dbnzx label
dbnz [],label
nega negx
neg []
coma comx
com []
lsra lsrx
lsr []
rora rorx
ror []
asra asrx
asla aslx
asl []
lsla lslx
lsl []
rola rolx
rol []
deca decx
dec []
inca incx
inc []
tsta tstx
tst []
clra clrx
clr [] clrh
aix #data
ais #data
sub [] cmp []
sbc [] cpx []
and [] bit []
lda [] sta []
eor [] adc []
ora [] add []
ldx [] stx []
mov [],[]
cphx []
ldhx []
sthx []
jmp [] jsr []
APPENDIX F
AS6809 ASSEMBLER
r,r1,r2 registers
cc,a,b,d,dp,x,y,s,u,pc
The terms data, dir, label, offset, and ext may all be expres−
sions.
Note that not all addressing modes are valid with every in−
struction, refer to the 6809 technical data for valid modes.
asla aslb
asl []
asra asrb
asr []
clra clrb
clr []
coma comb
com []
deca decb
dec []
inca incb
inc []
lsra lsrb
lsr []
nega negb
neg []
rola rolb
rol []
rora rorb
ror []
tsta tstb
tst []
adca [] adcb []
adda [] addb []
anda [] andb []
bita [] bitb []
cmpa [] cmpb []
eora [] eorb []
lda [] ldb []
ora [] orb []
sbca [] sbcb []
sta [] stb []
suba [] subb []
addd [] subd []
cmpd [] ldd []
std []
cmps [] cmpu []
cmpx [] cmpy []
lds [] ldu []
ldx [] ldy []
leas [] leau []
leax [] leay []
sts [] stu []
stx [] sty []
pshs r pshu r
puls r pulu r
jmp [] jsr []
aba cba
clc cli
clv des
dex ins
inx
ldaa [] ldab []
oraa [] orab []
psha pshb
pula pulb
sba sec
sei sev
staa [] stab []
tab tap
tba tpa
tsx txs
wai
APPENDIX G
AS6811 ASSEMBLER
The terms data, dir, offset, and ext may all be expressions.
Note that not all addressing modes are valid with every in−
struction, refer to the 68HC11 technical data for valid modes.
aba abx
aby cba
clc cli
clv daa
des dex
psha pshb
psh a psh b
pshx pshy
psh x psh y
pula pulb
pul a pul b
pulx puly
pul x pul y
asra asrb
asr a asr b
asr []
clra clrb
clr a clr b
clr label
coma comb
com a com b
com []
deca decb
inca incb
inc a inc b
inc []
nega negb
neg a neg b
neg []
rola rolb
rol a rol b
rol []
rora rorb
ror a ror b
ror []
tsta tstb
tst a tst b
tst []
adca [] adcb []
adc a [] adc b []
anda [] andb []
and a [] and b []
bita [] bitb []
bit a [] bit b []
cmpa [] cmpb []
cmp a [] cmp b []
eora [] eorb []
eor a [] eor b []
ldaa [] ldab []
lda a [] lda b []
oraa [] orab []
ora a [] ora b []
staa [] stab []
sta a [] sta b []
bclr [],#data
bset [],#data
brclr [],#data,label
brset [],#data,label
jmp [] jsr []
cpx [] cpy []
ldd [] lds []
ldx [] ldy []
std [] sts []
stx [] sty []
APPENDIX H
AS6812 ASSEMBLER
r,r1,r2 registers
ccr,a,b,d,x,y,sp,pc
The terms data, dir, label, offset, and ext may all be expres−
sions.
Note that not all addressing modes are valid with every in−
struction, refer to the 68HC12 technical data for valid modes.
bclr [],#data
bset [],#data
brclr [],#data,label
brset [],#data,label
asla aslb
asl []
asra asrb
asr []
clra clrb
clr []
coma comb
com []
deca decb
dec []
inca incb
inc []
lsla lslb
lsl []
lsra lsrb
lsr []
nega negb
rola rolb
rol []
rora rorb
ror []
tsta tstb
tst []
adca [] adcb []
adda [] addb []
anda [] andb []
bita [] bitb []
cmpa [] cmpb []
eora [] eorb []
sbca [] sbcb []
suba [] subb []
addd [] subd []
cpd [] <=> cmpd []
ldd [] std []
lds []
ldx [] ldy []
leas []
leax [] leay []
sts []
stx [] sty []
call [],pg
jmp [] jsr []
emacs []
emaxd [] emaxm []
emind [] eminm []
etbl []
maxa [] maxm []
mina [] minm []
tbl [] trap #data
APPENDIX I
AS6816 ASSEMBLER
r register
ccr,a,b,d,e,x,y,z,s
The terms data, label, offset, bank, and ext may all be expres−
sions.
Note that not all addressing modes are valid with every in−
struction, refer to the 6816 technical data for valid modes.
bclr [],#data
bset [],#data
brclr [],#data,label
brset [],#data,label
asla aslb
asld asle
aslm
asl [] aslw []
asra asrb
asrd asre
asrm
asr [] asrw []
clra clrb
clrd clre
clrm
clr [] clrw []
coma comb
comd come
com [] comw []
deca decb
dec [] decw []
inca incb
inc [] incw []
lsra lsrb
lsrd lsre
lsr [] lsrw []
nega negb
negd nege
neg [] negw []
rola rolb
rold role
rol [] rolw []
rora rorb
rord rore
ror [] rorw []
tsta tstb
tsta tste
tst [] tstw []
adca [] adcb []
adcd [] adce []
adda [] addb []
addd [] adde []
anda [] andb []
andd [] ande []
bita [] bitb []
cmpa [] cmpb []
cpd [] cpe []
eora [] eorb []
eord [] eore []
ldaa [] ldab []
ldd [] lde []
oraa [] orab []
ord [] ore []
sbca [] sbcb []
sbcd [] sbce []
staa [] stab []
std [] ste []
suba [] subb []
cps [] cpx []
cpy [] cpz []
lds [] ldx []
ldy [] ldz []
sts [] stx []
sty [] stz []
APPENDIX J
ASH8 ASSEMBLER
The terms data, dir, label, offset, and ext may all be expres−
sions.
Note that not all addressing modes are valid with every in−
struction, refer to the H8/3xx technical data for valid modes.
eepmov
nop
sleep
rte
Free Form
push rn pop rn
push.w rn pop.w rn
Free Form
sub rnB,rnB
sub rn,rn
subs #1,rn subs #2,rn
subx rnB,rnB subx #xx:8,rnB
or rnB,rnB or #xx:8,rnB
or #xx:8,ccr
sub.b rnB,rnB
sub.w rn,rn
Free Form
AS8051 ASSEMBLER
K.1 ACKNOWLEDGMENT
John L. Hartman
jhartman@compuserve.com
@r indirect on register r0 or r1
@dptr indirect on data pointer
@a+dptr indirect on accumulator
plus data pointer
@a+pc indirect on accumulator
plus program counter
The terms data, addr, bitaddr, and label may all be expressions.
Note that not all addressing modes are valid with every in−
struction. Refer to the 8051 technical data for valid modes.
nop
mov c,bitaddr
mov dptr,#data
clr a clr c
clr bitaddr
cpl a cpl c
cpl bitaddr
setb c setb bitaddr
da a
rr a rrc a
rl a rlc a
swap a
dec a dec r
dec @r
inc a inc r
inc dptr inc @r
div ab mul ab
ajmp label
cjne a,#data,label cjne a,addr,label
cjne r,#data,label cjne @r,#data,label
djnz r,label djnz addr,label
jbc bitadr,label
jb bitadr,label jnb bitadr,label
jc label jnc label
jz label jnz label
jmp @a+dptr
ljmp label sjmp label
APPENDIX L
AS8085 ASSEMBLER
Note that not all addressing modes are valid with every in−
struction, refer to the 8080/8085 technical data for valid
modes.
cma cmc
daa di
ei hlt
cc label rc
cm label rm
cnc label rnc
cnz label rnz
cp label rp
cpe label rpe
cpo label rpo
cz label rz
call label
jc label
jm label
jnc label
jnz label
jp label
jpe label
jpo label
jz label
jmp label
in data
out data
rst data
mov r1,r2
mov r,m
mvi r,#data
mvi m,#data
dcr r dcr m
inr r inr m
dad r dcx r
inx r ldax r
pop r push r
stax r
lxi r,#data
APPENDIX M
ASZ80 ASSEMBLER
Format:
.hd64
n byte value
rg a byte register
a,b,c,d,e,h,l
rp a register pair
bc,de,hl
The terms data, dir, offset, and ext may all be expressions.
The terms dir and offset are not allowed to be external refer−
ences.
Note that not all addressing modes are valid with every in−
struction, refer to the Z80/HD64180 technical data for valid
modes.
ld rg,[] ld [],rg
ld (bc),a ld a,(bc)
ld (de),a ld a,(de)
ld (label),a ld a,(label)
ld (label),rp ld rp,(label)
ld i,a ld r,a
ld a,i ld a,r
ld sp,hl ld sp,ix
ld sp,iy ld rp,#data
ldd lddr
ldi ldir
jp C,label jp M,label
jp NC,label jp NZ,label
jp P,label jp PE,label
jp PO,label jp Z,label
jp (hl) jp (ix)
jp (iy) jp label
djnz label
jr C,label jr NC,label
jr NZ,label jr Z,label
jr label
bit n,[]
res n,[]
set n,[]
im n
im n
im n
rst n
in a,(n) in rg,(c)
ind indr
ini inir
ex (sp),hl ex (sp),ix
ex (sp),iy
ex de,hl
push rp pop rp
in0 rg,(n)
out0 (n),rg
otdm otdmr
otim otimr
mlt bc mlt de
mlt hl mlt sp
slp
tst a
tstio #data
APPENDIX N
AS6500 ASSEMBLER
N.1 ACKNOWLEDGMENT
Marko Makela
Sillitie 10 A
01480 Vantaa
Finland
Internet: Marko.Makela@Helsinki.Fi
EARN/BitNet: msmakela@finuh
a − 8−bit accumulator
x,y − index registers
The terms data, dir, offset, address, ext, and label may all be
expressions.
Note that not all addressing modes are valid with every in−
struction, refer to the 65xx technical data for valid modes.
brk clc
cld cli
clv dex
dey inx
iny nop
pha php
pla plp
rti rts
sec sed
sei tax
tay tsx
txa txs
tya
asl []
dec []
inc []
lsr []
rol []
ror []
adc []
and []
bit []
cmp []
eor []
lda []
ora []
sbc []
sta []
jmp [] jsr []
cpx []
cpy []
ldx []
stx []
ldy []
sty []
rmb0 [] rmb1 []
rmb2 [] rmb3 []
rmb4 [] rmb5 []
rmb6 [] rmb7 []
smb0 [] smb1 []
smb2 [] smb3 []
smb4 [] smb5 []
smb6 [] smb7 []
bra label
phx phy
plx ply
rmb0 [] rmb1 []
rmb2 [] rmb3 []
rmb4 [] rmb5 []
rmb6 [] rmb7 []
smb0 [] smb1 []
smb2 [] smb3 []
smb4 [] smb5 []
smb6 [] smb7 []
bra label
phx phy
plx ply
rmb0 [] rmb1 []
rmb2 [] rmb3 []
rmb4 [] rmb5 []
rmb6 [] rmb7 []
smb0 [] smb1 []
smb2 [] smb3 []
smb4 [] smb5 []
smb6 [] smb7 []
stz []
trb []
tsb []
adc [] and []
cmp [] eor []
lda [] ora []
sbc [] sta []
bit [] jmp []
dec inc