| |||
| Home > Using the Inline and Embedded Assemblers of the ARM Compiler > Calling a nonvirtual member function | |||
Example 46 shows code that can be used to call a nonvirtual function in either a virtual or nonvirtual base:
Example 46. Calling a nonvirtual function
// rp contains a D* and we want to do the equivalent of rp->f() where f is a // nonvirtual function // all arguments other than the this pointer are already set up // assumes f does not return a struct if __mcall_is_in_vbase(D, f) LDR r12, [rp] // fetch vtable pointer LDR r0, [r12, #-__mcall_offsetof_vbase(D, f)] // fetch the vbase offset ADD r0, r0, rp // do this adjustment else ADD r0, rp, #__mcall_this_offset(D, f) // set up and adjust this // pointer for D* endif BL __cpp(&D::f) // call D::f