Jump to content
  • Advertisement
Sign in to follow this  
RiZeUp

C++ with inline ASM

This topic is 5196 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
{
public:
	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
Advertisement
Guest Anonymous Poster
Some compilers require symbols that are to be used in inline ASM to be defined globally.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!