Welcome! Log In Create A New Profile


assembler code

Posted by wilco2009 
assembler code
November 10, 2011 12:05AM
Somebody knows how is possible to insert ppc assembler code in a c for wii program?
I know the __asm () function but only allows to insert one assembler line.

thank you in advance
Re: assembler code
November 10, 2011 01:18AM
put it in a .s file. off the top of my head, i know that geckoOS has some asm in a .s. if you need something else to look at, you can grab its source code and dig around.

Edited 1 time(s). Last edit at 11/10/2011 01:19AM by giantpune.
Re: assembler code
November 10, 2011 01:47AM
You can put more than one line using inline asm by including the newline characters:
#define _CPU_ISR_Enable() \
	{ register u32 _val = 0; \
	  __asm__ __volatile__ ( \
		"mfmsr %0\n" \
		"ori %0,%0,0x8000\n" \
		"mtmsr %0" \
		: "=&r" ((_val)) : "0" ((_val)) \
	  ); \
If you plan on examining the assembly listing output from the compiler, this is the recommended method.

Otherwise you can use ; to separate instructions:
static inline void write32(u32 addr, u32 x)
	asm("stw %0,0(%1) ; eieio" : : "r"(x), "b"(0xc0000000 | addr));
Re: assembler code
November 10, 2011 08:59AM
@giantpune. Thank you, I'll examine Gecko OS source code. Could be very interesting.

@tueidj. Thank you. After read you answer it seems obvious. I didn't try it.
Sorry, only registered users may post in this forum.

Click here to login