Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 3,725 of 4,675    |
|    James Harris to James Harris    |
|    Re: Locals, parameters, callee-save regi    |
|    31 Dec 18 19:04:09    |
      From: james.harris.1@nospicedham.gmail.com              On 31/12/2018 17:20, James Harris wrote:              ...              > If you were not constrained by an existing convention (or even if you       > have a favourite convention) would you make space for locals before or       > after saving registers? Or would you, in fact, save registers before       > pushing EBP?       >       > I am thinking to do the latter. Will explain the reasons for that in a       > reply. But I guess it's unconventional and non-standard so I wondered       > what others thought or had found was the best thing to do.       >       > So the basic query is: if given free rein on x86 how would you recommend       > storing callee-save registers and locals while providing convenient       > access to stack-based parameters?              On that, it is often convenient to have a place to jump to in order to       make a sharp exit from a function irrespective of what the function code       has done to locals and the stack pointer in the meaning. The code at       that point would, ideally, not care about locals - which would be out of       scope by the time we got to the exit code. And it would ideally not have       to care about the stack pointer - which could have been modified by the       function code. That suggests that the first thing the exit code should       do is restore the stack pointer with               mov esp, ebp              Everything else that had to be restored, then, would be after that point       on the stack, so would have had to be placed there before saving the       frame pointer - which suggests the following procedure entry and exit       code, assuming just ESI and EDI need to be saved.              Entry code               push edi        push esi        push ebp        mov ebp, esp        sub esp, |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca