Mode control directives
Syntax
CODE
DATA
DATA8
DATA16
DATA32
DATA64
Description
These directives provide control over the assembly mode:
Directive | Description |
|---|---|
| Subsequent instructions are assembled, linked, and disassembled as code. |
| Subsequent instructions are assembled, linked, and disassembled as 8-bit data. |
| Subsequent instructions are assembled, linked, and disassembled as 16-bit data. |
| Subsequent instructions are assembled, linked, and disassembled as 32-bit data. |
| Subsequent instructions are assembled, linked, and disassembled as 64-bit data. |
The CODE and DATA directives set the assembly mode for code and data sections. This information is used by C-SPY and IAR ELF Dumper.
Note
The CODE or DATA directives are required for big-endian applications, but they improve the disassembly for all applications.
The CODE or DATA directives can be used for:
Starting a code/data producing a section fragment (
RSEGorSECTION) that actually generates bytes that end up in the image, either code or dataChanging the assembly mode in the middle of a section fragment.
The directive should come after the section fragment start (for example after the RSEG or SECTION directive) and immediately precede any code-generating part (instructions or DC declarations).
You do not need the CODE or DATA directives for declaring sections, extern labels etc, and not when you declare RAM space.
In big-endian mode, the two least significant address bits are inverted on the RXmicrocontroller. This means that the chip operates on four-byte chunks. If you change the byte order, as you do when you switch between the code and data assembly modes, you must make sure that each segment part begins on a 4-byte aligned address when you toggle the assembly mode between code and data, or linking will fail with an alignment error.
Example
In this example, the disassembly mode changes several times to accommodate different types of data:
name codedata
extern printStr
public printDate
section __DEFAULT_CODE_SECTION__:CODE
code ; Disassembled as code
printDate: mov.l #a_date,R1 ; Load address of date
; string in R0.
bsr printStr ; Call string output routine.
rts
data8 ; Disassembled as 8-bit data.
a_date:
dc8 __DATE__ ; String representing the
; date of assembly.
end