29.10.2014 Views

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Using</strong> <strong>the</strong> Inline and Embedded Assemblers of <strong>the</strong> <strong>ARM</strong> <strong>Compiler</strong><br />

7.47 Calling a nonvirtual member function<br />

Example 7-6 shows code that can be used to call a nonvirtual function in ei<strong>the</strong>r a virtual or<br />

nonvirtual base:<br />

Example 7-6 Calling a nonvirtual function<br />

// rp contains a D* and we want to do <strong>the</strong> equivalent of rp->f() where f is a<br />

// nonvirtual function<br />

// all arguments o<strong>the</strong>r than <strong>the</strong> this pointer are already set up<br />

// assumes f does not return a struct<br />

if __mcall_is_in_vbase(D, f)<br />

LDR r12, [rp]<br />

// fetch vtable pointer<br />

LDR r0, [r12, #-__mcall_offsetof_vbase(D, f)] // fetch <strong>the</strong> vbase offset<br />

ADD r0, r0, rp<br />

// do this adjustment<br />

else<br />

ADD r0, rp, #__mcall_this_offset(D, f)<br />

endif<br />

BL __cpp(&D::f)<br />

// set up and adjust this<br />

// pointer <strong>for</strong> D*<br />

// call D::f<br />

7.47.1 See also<br />

Concepts<br />

• Calling nonstatic member functions in embedded assembler on page 7-53.<br />

<strong>ARM</strong> DUI 0375C Copyright © 2007-2008, 2011 <strong>ARM</strong>. All rights reserved. 7-54<br />

ID061811<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!