Defining Absolute Sections in Assembly Source File

An absolute section is defined using the ORG directive. In that case, the Macro Assembler generates a pseudo section, whose name is "ORG_<index>", where index is an integer which is incremented each time an absolute section is encountered, as listed in the following listing:

Listing: Defining an absolute section containing data

       ORG   $800    ; Absolute data section.
var:   DS.   1

       ORG   $A00    ; Absolute constant data section.

cst1:  DC.B  $A6

cst2:  DC.B  $BC

In the previous portion of code, the label cst1 is located at address $A00, and label cst2 is located at address $A01.

Listing: Assembler output

1    1                       ORG   $800
2    2  a000800       var:   DS.B  1

3    3                       ORG   $A00

4    4  a000A00 A6    cst1:  DC.B  $A6

5    5  a000A01 BC    cst2:  DC.B  $BC

Locate program assembly source code in a separate absolute section, as listed in the following listing:

Listing: Defining an absolute section containing code

        XDEF  entry
        ORG   $C00 ; Absolute code section.

entry:

        LD D0,   cst1 ; Load value in cst1

        ADD D0,   cst2 ; Add value in cst2

        ST D0,   var  ; Store in var

        BRA   entry

In the portion of assembly code above, the LD D0, instruction is located at address $C00, and the ADD instruction is at address $C03. See the following listing:.

Listing: Assembler output

    8    8                              ORG   $C00 ; Absolute code
    9    9                       entry:

   10   10  a000C00 A4FA000A00         LD D0,   2560 ; Load value

   11   11  a000C05 64FA000A01         ADD D0   2561 ; Add value

   12   12  a000C0A C4FA000800         ST D0,   2561  ; Store in var

   13   13  A000C0F 2071                BRA   entry

   14   14

In order to avoid problems during linking or execution from an application, an assembly file should at least: