SPRUI04F july 2015 – april 2023
Define a Procedure
label .proc [variable1 [, variable2 , …]]
.endproc [register1 [, register2 , …]]
Use the .proc/.endproc directive pair to delimit a section of your code that you want the assembly optimizer to optimize. This section is called a procedure. Use .proc at the beginning of the section and .endproc at the end of the section. In this way, you can set off sections of unscheduled assembly instructions that you want optimized by the compiler. The directives must be used in pairs; do not use .proc without the corresponding .endproc. Specify a label with the .proc directive. You can have multiple procedures in a linear assembly file.
Use the optional variable parameter in the .proc directive to indicate which registers are live in, and use the optional register parameter of the .endproc directive to indicate which registers are live out for each procedure. The variable can be an actual register or a symbolic name. For example:
.PROC x, A5, y, B7
...
.ENDPROC y
A value is live in if it has been defined before the procedure and is used as an input to the procedure. A value is live out if it has been defined before or within the procedure and is used as an output from the procedure. If you do not specify any registers with the .endproc directive, it is assumed that no registers are live out.
Only code within procedures is optimized. The assembly optimizer copies any code that is outside of procedures to the output file and does not modify it.
See Section 5.4.1 for a list of instruction types that cannot appear in a .proc region.
Here is a block move example in which .proc and .endproc are used:
move .proc A4, B4, B0
.no_mdep
loop:
LDW *B4++, A1
MV A1, B1
STW B1, *A4++
ADD -4, B0, B0
[B0] B loop
.endproc