4.5.5 Using Executable Symbols in a Data Context

The DSC device modified-Harvard architecture includes separate address spaces for data storage and program storage. Most instructions and assembler directives imply a context which is compatible with symbols from one address space or the other. For example, the CALL instruction implies an executable context, so the assembler reports an error if a program tries to CALL a symbol located in a data section.

Likewise, instructions and directives that imply a data context cannot be used with symbols located in an executable section. Assembling the following code sequence will result in an error, as shown:

.text
msg:  .asciz "Here is an important message"
mov #msg,w0
:
:
Assembler messages:
Error: Cannot reference executable symbol (msg) in a data context

In this example the mov instruction implies a data context. Because symbol msg is located in an executable section, an error is reported. Possibly the programmer was trying to derive a pointer for use with the PSV window. The special operators described in 4.8 Special Operators can be used whenever an executable symbol must be referenced in a data context:

.text
msg:  .asciz "Here is an important message"
mov #psvoffset(msg),w0

Here the psvoffset() operator derives a 16-bit value which is suitable for use in a data context.

The next example shows how the special symbol “.” can be used with a data directive in an executable section:

.text
fred:  .long paddr(.)

Here the paddr() operator derives a 24-bit value which is suitable for use in a data context. The .long directive pads the value to 32 bits and encodes it into the .text section.