Keil Logo

ORG Assembler Statement

Arguments
ORG expression
Description

The ORG statement alters the location counter for the current segment and sets a new origin for subsequent statements. The expression must be a simple relocatable expression with no forward references. Only absolute addresses or symbol values in the current segment may be used. The dollar-sign character ('$'), which represents the current value of the location counter, may be used in the expression.

When the ORG statement is encountered, the assembler calculates the value of the expression and changes the location counter.

  • If the ORG statement appears in an absolute segment, the location counter is assigned the absolute address value specified. The location counter may not be set to an address below the base address of the segment.
  • If the ORG statement appears in a relocatable segment, the location counter is assigned the offset of the specified expression. For example, if the relocatable segment starts at address 1000h and if the ORG expression has a value of 1234h, the absolute address of the next statement is 2234h (1000h + 1234h).

The ORG statement changes the location counter, which may create a gap, but does not create a new segment.

 

  • It is possible to use the ORG statement to change the location counter and overwrite (or overlay) existing code or data. This is supported because of legacy programs that used this technique to define multiple variables at the same physical address. No warning is generated if the ORG statement is used this way.
See Also

SEGMENT

Example
ORG     100h
ORG     RESTART
ORG     EXIT1
ORG     ($ + 15) AND 0FFF0h

Related Knowledgebase Articles

  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.