4.9.41 Org Directive
The ORG
directive changes the value of the location
counter within the current psect. This means that the addresses set with
ORG
are relative to the base address of the psect, which is not
determined until link time.
ORG
directive does not
move the location counter to the absolute address you specify. Only if the psect in which
this directive is placed is absolute and overlaid will the location counter be moved to the
specified address. To place objects at a particular address, place them in a psect of their
own and link this at the required address using the linkers -P
option (see
6.1.19 P: Position Psect). The
ORG
directive is not commonly required in programs.The argument to ORG
must be either an absolute value, or
a value referencing the current psect. In either case, the current location counter is set
to the value determined by the argument. It is not possible to move the location counter
backward. For example:
ORG 100h
will move the location counter to the beginning of the current psect plus 100h. The actual location will not be known until link time.
In order to use the ORG
directive to set the location
counter to an absolute value, the directive must be used from within an absolute, overlaid
psect. For example:
PSECT absdata,abs,ovrld
ORG 50h
;this is guaranteed to reside at address 50h