Re: asm stackframe question

2012-04-08 Thread Stefan
On Saturday, 7 April 2012 at 23:50:42 UTC, bearophile wrote: Keep also in mind that D functions that contain ASM don't get inlined in DMD (and probably elsewhere too). BTW: The GCC backend has a pretty powerful ASM support where inlining IS possible and you can simply say things like 'give me

Re: asm stackframe question

2012-04-08 Thread Stefan
On Saturday, 7 April 2012 at 23:50:42 UTC, bearophile wrote: Use the "naked" attribute and do it all by yourself? Then I would also have to do the throw a) fully by myself (with mangling, etc), or b) at least get the stack frame in order so that the throw finds the stack the way it expects...

Re: asm stackframe question

2012-04-08 Thread Stefan
On Sunday, 8 April 2012 at 01:15:48 UTC, Timon Gehr wrote: The D calling convention leaves stack cleanup up to the callee. Either mark your function as extern(C) or use leave ret 16 The second option might not be portable across all currently available compilers though. Hi Timon, Works fi

Re: asm stackframe question

2012-04-07 Thread Timon Gehr
On 04/08/2012 12:13 AM, Stefan wrote: As a little learning exercise for D I’m writing a fixed point library. Part of this is checking standard integer operations for overflows. This is the code for adding 2 longs: int64 add64ov(int64 a, int64 b) { int64 res; asm { mov EAX,a ; mov EDX,a+4 ; add

Re: asm stackframe question

2012-04-07 Thread bearophile
Stefan: Ideas, anyone? Use the "naked" attribute and do it all by yourself? Keep also in mind that D functions that contain ASM don't get inlined in DMD (and probably elsewhere too). Bye, bearophile