First page Back Continue Last page Overview Graphics
Assembler Directive - switch
switch redirects the code or data that follows to the named program section. The section name must either be one of the predefined ones such as .text or .data or have been defined using the section directive.
- data1: section
- code1: section
- switch data1
- MotorDat: dc.b $a2
- switch code1
- ldaa #20
The switch directive sets the active assembler location counter to the specified section. If this is the first code in the section and an explicit origin is not defined, the offset in the section will be zero. As code or data is encountered the location counter is incremented by 1 with each byte of data or code. Offset addresses are assigned to each instruction or variable based on the value in the location counter. When the code is finally linked, the offset values assigned to instructions or variables are added to the section starting addresses defined in the linker setup. Sections from different program modules with the same names are linked together and placed in sequential memory.
A programmer can switch back to previous sections at any time.