Directives Reference

7.5.1FRAME ADDRESS

The FRAME ADDRESS directive describes how to calculate the canonical frame address for following instructions. You can only use it in functions with FUNCTION and ENDFUNC or PROC and ENDP directives.

Syntax

FRAME ADDRESS reg[,offset] where:

reg

is the register on which the canonical frame address is to be based. This

 

is sp unless the function uses a separate frame pointer.

offset

is the offset of the canonical frame address from reg. If offset is zero, you

 

can omit it.

Usage

Use FRAME ADDRESS if your code alters which register the canonical frame address is based on, or if it alters the offset of the canonical frame address from the register. You must use FRAME ADDRESS immediately after the instruction which changes the calculation of the canonical frame address.

Note

If your code uses a single instruction to save registers and alter the stack pointer, you can use FRAME PUSH instead of using both FRAME ADDRESS and FRAME SAVE (see FRAME PUSH on page 7-36).

If your code uses a single instruction to load registers and alter the stack pointer, you can use FRAME POP instead of using both FRAME ADDRESS and FRAME RESTORE (see FRAME POP on page 7-35).

Example

_fn

FUNCTION

; CFA (Canonical Frame Address) is value

 

 

; of sp on entry to function

 

STMFD

sp!, {r4,fp,ip,lr,pc}

 

 

FRAME PUSH {r4,fp,ip,lr,pc}

 

 

 

SUB

sp,sp,#4

;

CFA offset now changed

 

FRAME ADDRESS sp,24

;

- so we correct it

 

ADD

fp,sp,#20

 

 

 

FRAME ADDRESS fp,4

;

New base register

 

; code using fp to base call-frame on, instead of sp

7-34

Copyright © 2000, 2001 ARM Limited. All rights reserved.

ARM DUI 0068B

Page 316
Image 316
ARM VERSION 1.2 manual Is sp unless the function uses a separate frame pointer, Can omit it