Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Mar 1996 18:23:58 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        jdp@polstra.com, terry@lambert.org
Cc:        freebsd-hackers@FreeBSD.org, nate@sneezy.sri.com
Subject:   Re: GAS question
Message-ID:  <199603170723.SAA27501@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> > : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=D" (cf)
>> > : "0" (*eax),  "1" (*ebx),  "2" (*ecx)
>> 
>> This is GCC's "extended asm" syntax.  The documentation is in the GCC
>> info pages.  From the top-level node, follow the menu entry "C
>> Extensions", then "Extended Asm".

>Oh god, this sucks.

Does not.

>A VC++ C variable reference from an inline addembler statement:

>void
>foo( unsigned long locklist)
>{
>	unsigned long	delta;

>	...
>	__asm mov eax, delta
>	__asm mov ebx, locklist
>	...
>}

This is very primitive.  Instead of letting the compiler decide which
registers to use, you have to do all the register loading yourself.
This wastes your time, and wastes the cpu's time doing unnecessary
moves if the registers are already in suitable places (delta in eax
and locklist in ebx in the above).

>And Assembly for a C callable function (Win95 blue screen from a VXD,
>actually):

>IFSMgr_SYSMODAL_Message PROC C PUBLIC USES EBX EDI ESI \
>				pszMessage:DWORD, \
>				pszCaption:DWORD, \
>				dwFlags:DWORD

>	VxDCall	Get_Sys_VM_Handle	; handle in ebx
>	mov	eax, dwFlags
>	mov	ecx, pszMessage
>	mov	edi, pszCaption
>	VxDCall	SHELL_SYSMODAL_Message	; bluescreen with message
>	ret
>IFSMgr_SYSMODAL_Message	ENDP

Assembly for a C callable function in gas:

foo:
	ret

:-)

>A C function without any preamble/postamble, and block inline assembly:

>__declspec(naked) void
>_peneter(save_edx)
>{
>	_asm {
>		mov	eax, esp
>		pushfd
>		cli
>		push	eax
>		mov	edx, save_edx
>		...
>		popfd
>		ret
>	}
>}

The preamble/postamble can't be avoided for extern functions in gcc asm
(it's always needed for pic and profiling code anyway).  The above
should be written as an inline functions if the `...' part is short.

>Variable references are plain old variable references.  Why is GCC so
>complicated?

It's more powerful.  Plain old variable references are used, just not
in the part that looks like it will be processed by the assembler.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603170723.SAA27501>