Skip to main content

IAR Embedded Workbench for RL78 5.20

Calling functions in the Far code model

In this section:

A direct call using this code model is simply:

            call f:label24

When a function call is made via a function pointer, this code will be generated:

            name    callFuncPtr
            rseg    CODE:CODE
            extern  funcPtr

            mov     a, n:funcPtr+2 ; Load byte3 of function 
                                   ; address
            mov     cs, A
            movw    ax, n:funcPtr  ; Load function address
            call    ax             ; Make function call
            end

The address is stored in a register and is then used for calling the function. Calls via a function pointer reach the whole 32-bit address space.