.contrl

Name

.contrl --  controls the address range of jumps and calls

Syntax

.contrl expression

Description

The .contrl directive controls automatic code alteration by the assembler on instructions. This directive either decreases the number of bytes of the instruction (to optimize code), or increases the number of bytes of the jp, jmp and jsr instructions to avoid a range error. Note that in two-pass mode, the assembler can alter only those instructions which have their operand defined during pass 1, which excludes forward-reference operands. This is because the assembler must know the size of the instruction on pass 1. In optimize mode, the assembler can always choose the optimal size for these instructions.

The .contrl directive also allows maximum code size for all instructions to be selected for ease of patching code during debugging. The instructions all have maximum size operand fields, so any valid operand can be patched-in during debugging.

Control of the various options depends upon the three least-significant bits of the evaluated expression in the operand field (the expression must be defined during pass 1). Table 2-5 shows the options available, their associated bit weights and assembler default values. Table 2-6 shows the possible code alterations that may occur for the jump instructions.

The .contrl directive may be used throughout the program to enable or disable the alteration of code. Normally, it is desirable to disable code alteration of the instructions only during a block of code which must remain a fixed size (for example, a critical timing loop).

This directive takes precedence over any multi-pass optimization. Thus, if code reduction is disabled, no optimization will take place regardless of the number of passes.

Example

		.contrl 0	; disable all code alteration
		 .		; fixed size code block
		 .
		 .
		.contrl 3	; re-enable code alteration
	

defaultvalue (binary)jp (1-byte)jmp (2-byte)jmpl (3-byte)jsr (2-byte)jsrl (3-byte)descriptioneffects
*B'011jp or jmp or jmpljp or jmp or jmpljp or jmp or jmpljsr or jsrljsr or jsrljump range is increased if necessary and decreased if possiblethis is the default
 B'001jpjmp or jpjmpl or jmp or jpjsrjsrl or jsrjump range will not increaseerrors are generated if jumps are out of range
 B'010jp or jmp or jmpljmp or jmpljmpljsr or jsrljsrjump range will not decreasecode size will not be optimized
 B'000jpjmpjmpljsrjsrlassembly instructions are not changederrors are generated if jumps are out of range and code size is not optimized
 B'100, B'101, B'110 or B'111jmpljmpljmpljsrljsrllargest jump range is usedcode size is not optimal but useful when debug patching

For further code optimization notes, see Chapter 4.

					; default .CONTRL in effect
					; (code alteration enabled)
	BACK:				; label
			ret
					; note that following references to
					; BACK are not forward-references
			jmp BACK	; reduced to single byte (jp)
			jp BACK		; no change (jp)

					; note that following references to
					; FORWORD are forward references
					; assembler cannot alter these in two-
					; pass mode but can in optimize mode
			jmp FORWORD	; no change (jmp) in two-pass, else (jp)
			jp FORWORD	; no change (jp)
	FORWORD: