Keil Logo

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)
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.