<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>At one point Linux/x86 didn't use gcc, right? It used the same as the Win32/x86 backend?<BR>
<BR>
Anyway, on Win32/x86, small functions like:<BR>
<BR>
PROCEDURE F5(b : INTEGER) : INTEGER =<BR>BEGIN<BR> RETURN Word.Shift(0, b);<BR>END F5;<BR><BR>
result in:<BR>
<BR>
_T__F5:<BR> 004010C2: 55 push ebp<BR> 004010C3: 8B EC mov ebp,esp<BR> 004010C5: 81 EC 04 00 00 00 sub esp,4<BR><STRONG> 004010CB: 53 push ebx<BR> 004010CC: 56 push esi<BR> 004010CD: 57 push edi<BR></STRONG> 004010CE: 33 C0 xor eax,eax<BR><STRONG> 004010D0: 5F pop edi<BR> 004010D1: 5E pop esi<BR> 004010D2: 5B pop ebx<BR></STRONG> 004010D3: C9 leave<BR> 004010D4: C3 ret<BR><BR>
Now, I can grant that having a consistent frame is nice for stack walkability in a debugger in the absence of symbols, so I won't argue about push ebp, mov ebp, esp, sub esp,4, leave. (not sure leave is the state of the art, need to compare to current compiler output).<BR>
<BR>
But, this constant push ebx/esi/edi, pop edi/esi/ebx seems dumb. Doesn't it?<BR>
<BR>
Looking at the code, and how it avoids having multiple passes, it should be easy to at least track which registers are used, and go back and nop out the pushes, and avoid the pops entirely.<BR>
<BR>
Or possibly to move the function ahead up to three bytes, leaving three bytes of padding -- being sure to test recursive code..except anything with a function call, maybe leave alone. I ASSUME nop is faster than push, esp. when combined with saving the pops entirely, ESP. when there are presumably two and three byte nops, so the instruction count can be dropped, even if the byte count cannot easily.<BR>
<BR>
Thoughts?<BR>
<BR>
Nobody cares 'cause everyone else is using gcc and it handles these things well?<BR>
<BR>
- Jay<BR><br /><hr />Your smile counts. The more smiles you share, the more we donate. <a href='www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline' target='_new'>Join in!</a></body>
</html>