Table of Contents        Previous topic       Next topic       

ASSEMBLER DIRECTIVES->Other Assembler Directives->SETDP

SETDP      Set Direct Page

The direct page addressing mode can be used to access any page within the target machines memory space.

The actual page that is accessed depends upon the contents of the microprocessor's direct page register.  This is initially zero but can be changed at any time to any page value between $00 and $FF.  To set the direct page register to $14, use for instance the assembler instructions:

    LDA    #$14
    TFR    A,DP

After these instructions, the direct page addressing mode will access memory between $1400 and $14FF.

In order for the assembler to be able to translate an assembler instruction into the direct page addressing mode it needs to know the contents of the direct page register.  The SETDP directive gives the assembler this information.

Unless otherwise directed, the assembler assumes that this page is the zero page (ie page $0000 to $00FF).  However, if this direct page register has been set to say $14 as above, then the assembler directive:

    SETDP $14

should also be used.  The assembler can then when appropriate generate direct page addressing instructions for all addresses which evaluate to between $1400 and $14FF.

The general format for the directive is:

    SETDP <expression>    <comment>

where, for an absolute section, <expression> evaluates to a one byte value which specifies the page number that has been loaded into the direct page register.

For direct page addressing to be used in a relocatable section, the section must have type 'INPAGE'. The expression in the operand following SETDP should then evaluate to a section name.

The following example illustrates the use of SETDP for a relocatable section.

   1 0000                             section   extendedpage,data
   2 0000                   exdata1   rmb       $20
   3 0000                             section   directpage,data,inpage
   4 0000                   dpdata1   rmb       $20
   5 0000                             section   example,code
   6 0000 86 00                       lda       #directpage
   7 0002 1F 8B                       tfr       a,dp
   8 0004                             setdp     directpage
   9 0004 96 03                       lda       dpdata1+3
  10 0006 B6 00 03                    lda       exdata1+3

The value of SETDP is set to zero at the beginning of assembly and is reset to zero at the beginning of pass 2.