inline assembly question

Richard Henderson rth@cygnus.com
Fri Jan 23 13:30:00 GMT 1998


On Wed, Jan 21, 1998 at 11:13:16AM -0800, Ficus Kirkpatrick wrote:
> I am porting some code that uses the Metrowerks CodeWarrior compiler so 
> that it can be compiled with GCC, and I have some inline assembly that I
> can't seem to feed to GCC in the right way.  The code in question is for
> x86 processors, and the Metrowerks format is like this:
> 
> asm {
> 		push	ecx
> 		mov	ecx, [esp + 0xc]
> 		call	[esp + 8]
> 		pop	ecx
> 		ret
> }

The GNU as syntax would be

	pushl	%ecx
	movl	0xc(%esp), %ecx
	call	0x8(%esp)
	popl	%ecx
	ret

or perhaps

	void foo (void *fn, int data)
	{
	  __asm__("call %0" : : "g"(fn), "c"(data));
	}


r~



More information about the Gcc mailing list