Last edited · 9 revisions   




asm2 is a native 1802 Elf-OS assembler updated for Elf-OS 0.4.0

The source file extension must be .asm but the file extension is not used when invoking the assembler.  For example, asm2 test compiles the source file test.asm 


Up completion of assembly, asm2 produces a   .obj file.  link2 is required to convert the  .obj file to a binary file with the default file name  being a.out


Assembler Line Format:


label:   OPCODE   ARGUMENTS      ; Comments


Labels and comments are optional, and not all opcodes have arguments.  In 

addition to the 1802 instruction set, Edt/Asm provides 5  pseudo-opcodes:


  ORG    addr                Specify address for assembly

  DB     b1,b2,        Define a list of bytes in memory

  DB     'c1','c2'...'cn'    Define a list of chars in memory (for example, 'A')

  DW     w1,w2,...wn     Define a list of words in memory

  DS      n                       Define storage without assigning  a value

  END    start                End of assembly, also specifies a start address


LABEL: EQU  n             Value of n is in decimal or hex 


Where addr,bn,wn  can be a hex value such as 8000h or a decimal value such as 256.

A colon (:) is used to delimit a label.


Example Elf-OS restart program


F_MSG: EQU  034Bh      ; ELF-OS message vector

F_WARM: EQU  0CF00h    ; BIOS warm start vector

       ORG  2000h      ; start of program load address

       BR   START      ; branch around header

       DB   88h        ; 8th month-upper bit indicates extended hdr

       DB   14         ; the 14th day of the month

       DW   2021       ; the year

       DW   7          ; indicate that this is build 7 of the program

       DB   'BJM'      ; text for the Elf OS version command 

       DB   0          ; indicate end of ASCIIZ text string

START: SEP  R4         ; call to output msg to terminal

       DW   F_MSG       elf OS output msg address

       DB   'Rebooting Elf-OS ...',0

       LBR  F_WARM     ; branch to entry point of EPROM

       END  START      ; indicate the entry point for the y point for the program      


asm2 currently only supports simple arguments, arithmetic expressions

cannot be used.  When specifying registers, the register number may (but need

not) begin with R, for example:    LDN    R8


The high byte of a value can be obtained by addeing .1 to the end of a label,

for example:    LDI    STACK.1     will load the high byte of the address of

STACK.  .0 will obtain the low byte of a value, for example:   LDI   STACK.0