Date: Sun, 17 Mar 1996 12:20:28 -0700 (MST) From: Terry Lambert <terry@lambert.org> To: bde@zeta.org.au (Bruce Evans) Cc: jdp@polstra.com, terry@lambert.org, freebsd-hackers@FreeBSD.org, nate@sneezy.sri.com Subject: Re: GAS question Message-ID: <199603171920.MAA19795@phaeton.artisoft.com> In-Reply-To: <199603170723.SAA27501@godzilla.zeta.org.au> from "Bruce Evans" at Mar 17, 96 06:23:58 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> >Oh god, this sucks. > > Does not. [ ... ] > 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). Excuse me. If I wanted the compiler to decide this, I would have written it in C. I wrote it in assembly because there exists an API of which the compiler is ignorant that depends on particular registes being used. It's not my fault that the assembler is too stupid to reorder instructions, and that optimization in GCC takes place using quad tree operations and during code generation, instead of where it should. > >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 > > :-) I don't see you handling C parameters or obeying register saves for calling conventions or dealing automatically with "callee pop" or any of a large number of other issues that using a real optimizing macroassembler would handle for you. > >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. This code gets the profiling calls, if profililing options are specified on the compilation line. There *is* an assumption about ESP. The "naked" "declspec" (sucky syntax, I know) avoids the "normal" "C-ification" of the code. > >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. I'm missing something. Why does complexity == power? Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603171920.MAA19795>