Inline assembly question

Dibyendu Majumdar d.majumdar at gmail.com
Sun Nov 12 22:20:46 UTC 2017


On Sunday, 12 November 2017 at 22:00:58 UTC, Basile B. wrote:
> On Sunday, 12 November 2017 at 21:27:28 UTC, Dibyendu Majumdar

>> Does the compiler generate appropriate unwind information on 
>> Win64? Prsumably if a function is marked 'naked' then it 
>> doesn't?
>>
> yeah about stack frame..., also don't forget to mark the asm 
> block "pure nothrow" if possible...
> It's not documented but the syntax is like that:
>
> ```
> void foo()
> {
>     asm pure nothrow
>     {
>         naked;
>         ret;
>     }
> }
>
> ```

I am not sure I have understood above; will DMD generate the 
right Win64 unwind info for this contrived example:

int luaV_interp(lua_State *L)
{
	asm pure nothrow {
		naked;
		push RDI;
		push RSI;
		push RBX;
		push R12;
		push R13;
		push R14;
		push R15;
		sub RSP, 5*8;
		mov  RAX, 0;
		add RSP, 5*8;
		pop R15;
		pop R14;
		pop R13;
		pop R12;
		pop RBX;
		pop RSI;
		pop RDI;
		pop RBP;
		ret;
	}
}




More information about the Digitalmars-d-learn mailing list