Re:How an Engineering Company Chose to Migrate to D
by WalterBright on Thursday June 21, 2018 @04:29PM
(#17369016)
The ENTER and LEAVE instructions only supported dynamic linking (pointer to caller's stack frame) not static linking (pointer to the enclosing function's stack frame).
Re:How an Engineering Company Chose to Migrate to D
by JdeBP on Friday June 22, 2018 @10:13AM
(#17374081)
That is not in fact true.
ENTER copies M words from the caller's stack frame. The pointer passed by MetaWare High C/C++ in the register could equally well have been placed at the relevant position in the caller's stack frame, just as other arguments are, and an ENTER N,1 used as part of the perilogue.
The only consideration here is speed of the ENTER instruction versus having the hidden pointer in a register, not that this sort of nested function implementation is somehow impossible with ENTER. It's just another case of ENTER is slow and other instructions do the same thing better.
* http://jdebp.info./FGA/function-perilogues.html#Standardx86
(Part of that consideration is making non-nested functions usable via full function pointers.)
Re:How an Engineering Company Chose to Migrate to D
by WalterBright on Saturday June 23, 2018 @05:55PM
(#17383664)
You're right.
* http://jdebp.info./FGA/metaware-iterator-driven-for.html
In theory, the extra frame pointer mechanisms of the ENTER and LEAVE instructions in the Intel ISA were there for supporting this kind of nested function. MetaWare High C/C++ did not use them, preferring to use a variant calling convention where (if I recall correctly) ECX contained the extra hidden parameter.