Sign in to follow this  

C++ with inline ASM

Recommended Posts

I've been looking around to find some info about this but my knowledge in ASM is way too limited to get any working. I am currently getting a "undefined reference" error in my ASM code of my project. I have heard C++ mangles names and functions when it compiles therefor my ASM code can't find the necessary variables. Here's my code. It has a hard time finding mp in sendMB(). I tried using extern "C" with no luck.
class CMultiplayer
	MBStruct mp;	
	void DelayCycles(u32 cycles);
	u16 send(u16 send);
	void sendMB();
void CMultiplayer::sendMB()

	// Execute BIOS routine to transfer client binary to slave unit
	asm volatile (
	  " ldr r0,=mp\n"
	  " mov r1,#1\n"
	  " swi 0x25\n"  /* for ARM change to 0x00250000 */
	  ::: "r0","r1","r2","r8","r9","r10","r11","r12"

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
I forgot to mention that I am using G++.

You sure fooled me.

One thing you could do is use a global pointer and have it point to mp. You'd then just used in pointer in the ASM part. I would only resort to this solution, however, if your compiler exhibits the behavior that I mentioned in my earlier post.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this