You copied the Doc URL to your clipboard.

21.41 FUNCTION or PROC

The FUNCTION directive marks the start of a function. PROC is a synonym for FUNCTION.

Syntax

label FUNCTION [{reglist1} [, {reglist2}]]

where:

reglist1

is an optional list of callee-saved ARM registers.If reglist1 is not present,and your debugger checks register usage, it assumes that the AAPCSis in use. If you use empty brackets, this informs the debuggerthat all ARM registers are caller-saved.

reglist2

is an optional list of callee-saved VFP registers.If you use empty brackets, this informs the debugger that all VFPregisters are caller-saved.

Usage

Use FUNCTION to mark the start of functions.The assembler uses FUNCTION to identify thestart of a function when producing DWARF call frame informationfor ELF.

FUNCTION sets the canonical frame addressto be R13 (SP), and the frame state stack to be empty.

Each FUNCTION directive must have amatching ENDFUNC directive. You must notnest FUNCTION and ENDFUNC pairs,and they must not contain PROC or ENDP directives.

You can use the optional reglist parametersto inform the debugger about an alternative procedure call standard,if you are using your own. Not all debuggers support this feature.See your debugger documentation for details.

If you specify an empty reglist,using {}, this indicates that all registers forthe function are caller-saved. Typically you do this when writinga reset vector where the values in all registers are unknown onexecution. This avoids problems in a debugger if it tries to constructa backtrace from the values in the registers.

Note

FUNCTION does not automatically causealignment to a word boundary (or halfword boundary for Thumb). Use ALIGN ifnecessary to ensure alignment, otherwise the call frame might notpoint to the start of the function.

Examples

       ALIGN        ; Ensures alignment.dadd   FUNCTION     ; Without the ALIGN directive this might not be word-aligned.       EXPORT  dadd        PUSH       {r4-r6,lr}    ; This line automatically word-aligned.       FRAME PUSH {r4-r6,lr}       ; subroutine body       POP        {r4-r6,pc}       ENDFUNCfunc6  PROC {r4-r8,r12},{D1-D3} ; Non-AAPCS-conforming function.       ...       ENDPfunc7  FUNCTION {}  ; Another non-AAPCS-conforming function.       ...       ENDFUNC
Was this page helpful? Yes No