Absolute sections

The starting address of an absolute section is known at assembly time. An absolute section is defined through the ORG - Set Location Counter assembler directive. The operand specified in the ORG directive determines the start address of the absolute section. The following listing shows an example of constructing absolute sections using the ORG assembler directive.

Listing: Example source code using ORG for absolute sections

      XDEF  entry
      ORG   $8000 ; Absolute constant data section.

cst1: DC.B  $26

cst2: DC.B  $BC

...

      ORG   $080  ; Absolute data section.

var:  DS.B  1

      ORG   $8010 ; Absolute code section.

entry:

      LD D0,cst1  ; Loads value in cst1

      ADD D0,cst2  ; Adds value in cst2

      ST D0,var   ; Stores result into var

      BRA   entry

In the previous example, two bytes of storage are allocated starting at address $A00. The constantvariable - cst1 - will be allocated one byte at address $8000 and another constant - cst2 - will be allocated one byte at address $8001. All subsequent instructions or data allocation directives will be located in this absolute section until another section is specified using the ORG or SECTION directives.

When using absolute sections, it is the user's responsibility to ensure that there is no overlap between the different absolute sections defined in the application. In the previous example, the programmer should ensure that the size of the section starting at address $8000 is not bigger than $10 bytes, otherwise the section starting at $8000 and the section starting at $8010 will overlap.

Even applications containing only absolute sections must be linked. In that case, there should not be any overlap between the address ranges from the absolute sections defined in the assembly file and the address ranges defined in the linker parameter (PRM) file.

The PRM file used to link the example above, can be defined as the following listing displays.

Listing: Example PRM file for linking source code using ORG for absolute sections

LINK  test.abs /* Name of the executable file generated.     */
NAMES test.o   /* Name of the object file in the application */

END

SECTIONS

/* READ_ONLY memory area. There should be no overlap between this

   memory area and the absolute sections defined in the assembly

   source file. */

  MY_ROM  = READ_ONLY  0x8000 TO 0xFDFF;

/* READ_WRITE memory area. There should be no overlap between this

   memory area and the absolute sections defined in the assembly

   source file. */

  MY_RAM  = READ_WRITE 0x0100 TO 0x023F;

END

PLACEMENT

/* Relocatable variable sections are allocated in MY_RAM.          */

  DEFAULT_RAM, SSTACK INTO MY_RAM;

/* Relocatable code and constant sections are allocated in MY_ROM. */

  DEFAULT_ROM         INTO MY_ROM;

END

STACKSTOP $014F /* Initializes the stack pointer */

INIT   entry /* entry is the entry point to the application.   */

VECTOR ADDRESS 0xFFFE entry /* Initialization for Reset vector.*/

The linker PRM file contains at least: