Ax51 User's Guide

Location Counter

The Ax51 assembler maintains a location counter for each segment which contains the offset of the instruction or data being assembled. The location counter increments after each line by the number of bytes of code or data in that line.

The location counter is initialized to 0 for each segment, but may be changed using the ORG statement.

The dollar sign character ('$') may be used in an expression to obtain the current value of the location counter. For example, the following uses the location counter to determine the length of a string.

msg:      DB      'This is a message', 0
msg_len:  EQU     $-msg

You may use the location counter in instructions. For example, the following creates an infinite loop:

          JMP     $      ; While (1)