SPRUI04F july 2015 – april 2023
Declare Symbolic Registers
.reg symbol1 [, symbol2 , …]
The .reg directive allows you to use descriptive names for values that are stored in registers. The assembly optimizer chooses a register for you such that its use agrees with the functional units chosen for the instructions that operate on the value.
The .reg directive is valid within procedures only; that is, within occurrences of the .proc and .endproc directive pair or the .cproc and .endproc directive pair.
Declaring register pairs (or register quads for C6600) explicitly is optional. Doing so is only necessary if the registers should be allocated as a pair, but they are not used that way. It is a best practice to declare register pairs and register quads with the pair/quad syntax. Here is an example of declaring a register pair:
.regA7:A6
This example uses the same code as the block move example shown for .proc/.endproc but the .reg directive is used:
move .cproc dst, src, cnt
.reg tmp1, tmp2
loop:
LDW *src++, tmp1
MV tmp1, tmp2
STW tmp2, *dst++
ADD -4, cnt, cnt
[cnt] B loop
Notice how this example differs from the .proc example: symbolic registers declared with .reg are allocated as machine registers.
The code in the following example is invalid, because a variable defined by the .reg directive cannot be used outside of the defined procedure:
move .proc A4
.reg tmp
LDW *A4++, top
MV top, B5
.endproc
MV top, B6 ; WRONG: top is invalid outside of the procedure