asm1802Doc
Asm1802 Manual
Introduction
The asm1802 assembler is used to convert ASCII files into files that can be loaded into and exectuted by 1802 based computers. The following options are supported on the command line.
-format_intel Intel hex format
-format_ted Ted's hex format(default)
-format_elf_os Elf/OS binary format
-I include_path Directory for include files
Input lines can be blank, contain an optional label and statement or just a label. Labels must end with a : and the ; character is used to mark the beginning of a comment that goes to the end of the line.
The following sections describe various types of instructions.
Data Movement Instructions
ld src (d=src) Load D register with 8-bit value of src.
st dest (dest=d)
Store D register to 8-bit destination.
Arithmetic Instructions
inc dest (dest=dest + 1) Increment destination by 1. Treat destination register as a single 16-bit value.
dec dest (dest=dest + 1) Decrement destination by 1. Treat destination register as a single 16-bit value.
or src (d = d | src) Perform logical OR of D register with src value.
xor src (d = d ^ src) Perform exclusive OR of D register with src value.
and src (d = d & src) Perform logical AND of D register with src value.
add src (d = d + src) Add src to D register. Carry is loaded into DF.
addc src (d = d + src + DF) Add src and DF to D register. Carry is loaded into DF.
sub src1,src2 (d = src1 - src2) Perform src1 minus src2 and place result into D register. Borrow is loaded into DF. DF is 1 if no borrow was required.
subb src1,src2 (d = src1 - src2 - ~DF) Perform src1 minus src2 minus inverted DF and place result into D register. Borrow is loaded into DF. DF is 1 if no borrow was required.
shr (d = {0,d[7:1]}, DF = d[0]) Shift D register right by one and load DF with LSB of D.
ror (d = {DF,d[7:1]}, DF = d[0]) Rotate D register right by one through DF flag.
shl (d = {d[6:0],0}, DF = d[7]) Shift D register left by one and load DF with MSB of D.
rol (d = {d[6:0],DF}, DF = d[7]) Rotate D register left by one through DF flag.
Program Flow Instructions (short branch)
br dest
Unconditionally branch to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label.
nbr dest
No branch to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label. This is a NOP which takes up 2 bytes.
bz dest (if D==0)
Branch if D register is zero to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label.
bnz dest (if D!=0)
Branch if D register is non-zero to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label.
bdf dest (if DF==1) also bpz or bge
Branch if DF flag is one to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label.
bnf dest (if DF==0) also bm or bl
Branch if DF flag is zero to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label.
bq dest (if Q==1)
Branch if Q flag is one to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label.
bnq dest (if Q==0)
Branch if Q flag is zero to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label.
bx dest (if EFx==1) where x is 1 to 4
Branch if external flag EFx is one to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label.
bnx dest (if EFx==0) where x is 1 to 4
Branch if external flag EFx is zero to 16-bit destination which resides in the current 256 byte page. The assembler will check to make sure that the high 8 bits match the high 8-bits of the current address. Dest can be specified as a numeric constant or label.
skp
Skip over next byte.
Program Flow Instructions (long branch)
lbr dest
Unconditionally branch to 16-bit destination. Dest can be specified as a numeric constant or label.
nlbr dest
Do not branch to 16-bit destination. Dest can be specified as a numeric constant or label. This is a three byte NOP.
lbz dest (if D==0)
Branch if D register is zero to 16-bit destination. Dest can be specified as a numeric constant or label.
lbnz dest (if D!=0)
Branch if D register is non-zero to 16-bit destination. Dest can be specified as a numeric constant or label.
lbdf dest (if DF==1)
Branch if DF flag is one to 16-bit destination. Dest can be specified as a numeric constant or label.
lbnf dest (if DF==0)
Branch if DF flag is zero to 16-bit destination. Dest can be specified as a numeric constant or label.
lbq dest (if Q==1)
Branch if Q flag is one to 16-bit destination. Dest can be specified as a numeric constant or label.
lbnq dest (if Q==0)
Branch if Q flag is zero to 16-bit destination. Dest can be specified as a numeric constant or label.
lskp
Skip over next two bytes
lsz (if D==0)
Skip over next two bytes if D register is zero.
lsnz (if D!=0)
Skip over next two bytes if D register is non-zero.
lsdf (if DF==1)
Skip over next two bytes if DF flag is one.
lsnf (if DF==0)
Skip over next two bytes if DF flag is zero.
lsq (if Q==1)
Skip over next two bytes if Q flag is one.
lsnq (if Q==0)
Skip over next two bytes if Q flag is zero.
lsie (if IE==1)
Skip over next two bytes if IE (interrupt enable) flag is one.
Special Function Instructions
idle
Idle till interrupt. After return from interrupt program flow will continue with the next instruction.
nop
Perform no operation. Waste one byte and three machine cycles.
sep reg (reg is 0 to 15)
Set P (program counter) to be reg.
sex reg (reg is 0 to 15)
Set X (stack pointer) to be reg.
seq
Set Q flag to be one.
req
Set Q flag to be zero.
sav (Memory[Rx] = T)
Write 8-bit T register to to the memory location pointed to by the register designated as the by the X register. The T register is loaded with {X,P} in response to an interrupt.
mark (T = {X,P}, Memory[R2]=T, X=P, R2=R2-1)
Push X and P onto stack and change stack pointer to be program counter
ret ({X,P} =Memory[Rx], Rx=Rx+1, IE=1)
Restore X and P, pop stack pointer and enable future interrupts. This is used to return from an interrupt and enable future interrupts.
dis ({X,P} =Memory[Rx], Rx=Rx+1, IE=0)
Restore X and P, pop stack pointer and disable future interrupts. This is used to return from an interrupt but disabled future interrupts.
Pseudo Ops
.desc Description
Place Description of program into output file if the output format selected supports this feature. Note that the description must be in quotes.
Example:
.desc "This program is able to run without"
.desc "a keyboard."
.org Address
Set Address to assemble next instruction.
.pagefit Amount,FillValue
Make sure Amount bytes are free in the current page. If not, fill the remainder of the page with FillValue so that the next instruction will assemble into a new page. This is useful for making sure a small loop can be placed into a single page so that a short branch can be used.
.start Address
Set address to start program.
.title Description
Set the title of the program to Description. Description must be placed inside quotes.
.include File
Read File and include it into current source. File must be enclosed in quotes. The path to the file can be specified on the command line with the -I option.
.def Symbol Value
Define Symbol and set it equal to Value.
.byte Value [,Value ...]
Place Value and subsequent values into the output. Value can be single values, character constants or a string. Each value will be truncated to 8-bits.
.word Value[,Value ...]
Place Value and subsequent values into the output. Value can be single values, character constants or a string. Each value will be truncated to 16-bits.
.res Amount
Reserve Amount bytes.
.ifdef Symbol
Assemble instructions following this statement up until either a .else or .endif if Symbol has been defined with a .def or a label.
.else
Assemble instructions following this statement up until a .endif pseudo op if the prior .ifdef was false.
.endif
End marker for a block started with .ifdef or .else.
.align
Skip ahead to start of next page before starting to assemble.