SPRUI04F july 2015 – april 2023
Reserve a Register
.reserve [register1 [, register2 , …]]
The .reserve directive prevents the assembly optimizer from using the specified register in a .proc or .cproc region.
If a .reserved register is explicitly assigned in a .proc or .cproc region, then the assembly optimizer can also use that register. For example, the variable tmp1 can be allocated to register A7, even though it is in the .reserve list, since A7 was explicitly defined in the ADD instruction:
.cproc
.reserve a7
.reg tmp1
....
ADD a6, b4, a7
....
.endproc
When inside of a .cproc region that contains a .call statement, A4 and A5 cannot be specified in a .reserve statement. The calling convention mandates that A4 and A5 are used as the return registers for a .call statement.
The .reserve in this example guarantees that the assembly optimizer does not use A10 to A13 or B10 to B13 for the variables tmp1 to tmp5:
test .proc a4, b4
.reg tmp1, tmp2, tmp3, tmp4, tmp5
.reserve a10, a11, a12, a13, b10, b11, b12, b13
.....
.endproc a4
The assembly optimizer may generate less efficient code if the available register pool is overly restricted. In addition, it is possible that the available register pool is constrained such that allocation is not possible and an error message is generated. For example, the following code generates an error since all of the conditional registers have been reserved, but a conditional register is required for the variable tmp:
.cproc ...
.reserve a1,a2,b0,b1,b2
.reg tmp
....
[tmp] ....
....
.endproc