narrowed down the problem area [naked asm]

Don nospam at nospam.com
Mon Nov 3 03:06:04 PST 2008


Walter Bright wrote:
> Christian Kamm wrote:
>> Walter Bright wrote:
>>> I should add that 'naked' is for people who don't mind getting intimate
>>> with how the compiler arranges things. Any code using it should expect
>>> it to not be portable, and be past the compiler wagging its finger at
>>> them.
>>
>> Here portable means 'portable between different compilers for the same
>> architecture'?
>> I'm wondering because I thought the point of specifying inline 
>> assembler was
>> exactly to guarantee that kind of portability. So you would not 
>> consider a
>> compiler that does not implement naked, or handles it differently from 
>> DMD
>> to be breaking the D specification?
> 
> Since the stack prolog/epilog is not defined in the D ABI, a compiler is 
> free to innovate in this area.

That's great, and should be in the documentation.
However, I don't think there's any reason for the prolog to interfere 
with an all-assembler naked function.
Accessing a stack parameter by name from inside a naked asm function 
should either be:
* defined as implementation-dependent; or
* assume nothing about the way the variable is referenced, and should be 
independent of the stack prolog. (This could also be achieved with 
another 'magic' constant, similar to LOCALSIZE, giving the size of the 
stack frame for that function; so that var+FRAMESIZE is constant, 
regardless of the vendor).
For now, you could add a line to the docs stating that "accessing stack 
params and variables from naked asm functions is not yet standardized".


> The reason to specify the inline assembler is to have a common ground on 
> the assembler syntax.



More information about the Digitalmars-d mailing list