StephenHermer.com
Writing, Iguanas, and Electronics

Assembler Constructs

These language constructs are not part of the assembled code, but are used by the assembler when creating that code.

Labels

Labels have several purposes in the assembler, but always act as a starting address. The common usage is to put labels into the source code to act as targets for jumps and branches. A second use of labels is to define variables. Labels can appear on their own line, or on the line they point to. When on their own line, they point to the address of the next line.

start:
   MOV F #000F    ; Load 15 into the "F"-register
   MOV B #0001    ; Load 1 into the "B"-register
loop:
   SUB A, B       ; F = F - B.
   BNZ loop       ; Branch to loop if the zero flag is not set
   HLT

 

message: "Hello World" ; Create a string variable
   MOV message, X      ; Load the first address into the "X"-register
loop:
   MOV MEM[X], A       ; Load a value into the "A"-register

   INC X               ; Increment the "X"-register
   JMP loop            ; Loop back for the next value.