Keil Logo

PROC Assembler Statement

Arguments
name PROCtypeUSING regbank
name PROC TASKtaskname〛 〚INTNOintname〛〚= intno〛〛
name PROC INTERRUPT intname = intno USING regbank
Description

The PROC statement defines a procedure.

Where:

name specifies the name of the procedure.
PROC specifies that the procedure is a standard procedure function.
type specifies that the procedure is near or far. If no type is specified, the assembler assumes near regardless of the selected CPU mode (segmented or non-segmented). The assembler uses the procedure type to automatically generate the appropriate CALL and RET instructions.
PROC TASK specifies that the procedure is a TGROUP task procedure. A TGROUP task is a unit with one or more modules. The entry point to the task is the task procedure and the exit point from the task is a RETI instruction contained in the task procedure. A task is a unit that performs a certain function. It is activated by a software or hardware trap that causes an interrupt and that branches to the task procedure using an entry in the interrupt vector table.
taskname specifies the TGROUP for the task procedure. If no taskname is specified, an unnamed task procedure is created. The taskname must be unique and, if specified, intname and its value are GLOBAL symbols.
intname specifies a unique symbolic name for the interrupt vector of the task procedure or interrupt procedure. If the intname is not assigned an intno, the interrupt or vector number is relocatable and may be supplied by the linker.

For task procedures, the symbolic trap number activates tasks through a trap instruction which has a trap number as its operand. The trap name is known automatically system-wide.
intno specifies a numeric expression that evaluates to a constant value from 0-127 which represents the interrupt number of the interrupt procedure. The intno is assigned to intname (if specified).
PROC INTERRUPT specifies that the procedure is an interrupt service routine.
USING specifies the register bank that the procedure uses.
regbank specifies the name of a register bank that has been previously defined with the REGBANK directive.

Procedures must include a RET instruction which the assembler converts into one of the following machine return instructions:

  • RETS: Return from far procedure.
  • RETI: Return from interrupt procedure.
  • RET: Return from near procedure.

Procedures defined with the PROC statement must be terminated by the ENDP statement.

Note

  • Unlike procedures and functions created in high-level languages (like C and C++), identifier scope in assembly language is module-wide. For this reason, identifiers used in assembly procedures must be unique.
  • Procedures defined with the PROC statement may be called from within the same code segment (a near call) or may be called from a different code segment (a far call). They may be created as either near or far procedures (specified by the type).
  • The assembler does not verify whether or not a return instruction was used in a procedure. This is the responsibility of the programmer.
See Also

ENDP

Example
$SEGMENTED

MyBank1 REGBANK ; Register bank for Standard Proc
MyBank2 REGBANK ; Register bank for Interrupt Proc


C100    SECTION CODE

int10 PROC INTERRUPT I10=10 USING MyBank2
        MOV     MyBank2,R0
        SCXT    CP,#MyBank2
        NOP
        ; ...
        POP CP
        RET
int10 ENDP

proc1 PROC USING MyBank1
        MOV     MyBank1,R0
        SCXT    CP,#MyBank1
        NOP
        ; ...
        POP     CP
        RET
proc1 ENDP

C100    ENDS



C101    SECTION CODE

P101 PROC NEAR
        CALL    P102 ; far call for P102
        RET          ; near return
P101 ENDP

P102 PROC FAR
        CALL    P101 ; near call for P101
        TRAP    #I10 ; call int10
        RET          ; far return
P102 ENDP

C101    ENDS


C102    SECTION CODE
P103 PROC TASK TG1 INTNO I20=20
        NOP
        ; ...
        RET
P103 ENDP
C102    ENDS

        END

Related Knowledgebase Articles

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.