Table of Contents        Previous topic       Next topic       

C COMPILER->In Line Assembler Code->Accessing Local Variables and Function Parameters->Non-Reentrant Functions Small Memory Model

Non-Reentrant Functions, Small Memory Model

The local variables and function parameters are in idata and must be accessed by R0 or R1, except for _bit variables which are located in bit addressable data space.

void func(unsigned char Var1, unsigned char Var2)
    _bit BitVar;
    unsigned char Var3, Var4;
    _asm(     mov r0,#{Var1});
    _asm(     mov a,@r0);
    _asm(     mov r1,#{Var2});
    _asm(     mov a,@r1);
    _asm(     mov r0,#{Var3});
    _asm(     mov a,@r0);
    _asm(     mov r1,#{Var4});
    _asm(     mov a,@r1);
    _asm(    mov c,{BitVar});

compiles to:

    mov r0,#__frame_func-1
    mov a,@r0
    mov r1,#__frame_func-2
    mov a,@r1
    mov r0,#__frame_func
    mov a,@r0
    mov r1,#__frame_func+1
    mov a,@r1
    mov c,__bit_frame_func

;   Function 'func' Internal Objects
;   unsigned char _idata Var1      __frame_func-1
;   unsigned char _idata Var2      __frame_func-2
;   _bit BitVar                                 __bit__frame_func+0
;   unsigned char _idata Var3      __frame_func+0
;   unsigned char _idata Var4      __frame_func+1