digitalmars.D.learn - inline asm return values
- Dave Jones (18/18) Mar 25 2018 Given this...
- kinke (7/9) Mar 25 2018 See https://dlang.org/spec/abi.html#function_calling_conventions.
- Dave Jones (2/12) Mar 25 2018 Thanks!
Given this... int mulDiv64(int a, int b, int c) { asm { mov EAX,a; imul b; idiv c; } } which computes a*b/c, with the intermediate value in 64 bit. It returns value that is left in EAX. Is this stuff documented somewhere? I mean I found the page on inline asm but it's pretty sparse. I'm porting code from C++ and tested it so it works, but it'd be nice to be able to look up the rules on how to do return values with asm without having to dump it to the stack and then return that. Is the inline asm portable between compilers?
Mar 25 2018
On Sunday, 25 March 2018 at 10:58:37 UTC, Dave Jones wrote:Is this stuff documented somewhere?See https://dlang.org/spec/abi.html#function_calling_conventions. It defines the D calling convention for Win32 (int return value in EAX) and states that it matches the C calling convention on all other platforms [but note that the args are actually reversed].Is the inline asm portable between compilers?LDC supports the DMD-style inline asm too, GDC doesn't.
Mar 25 2018
On Sunday, 25 March 2018 at 12:23:03 UTC, kinke wrote:On Sunday, 25 March 2018 at 10:58:37 UTC, Dave Jones wrote:Thanks!Is this stuff documented somewhere?See https://dlang.org/spec/abi.html#function_calling_conventions. It defines the D calling convention for Win32 (int return value in EAX) and states that it matches the C calling convention on all other platforms [but note that the args are actually reversed].Is the inline asm portable between compilers?LDC supports the DMD-style inline asm too, GDC doesn't.
Mar 25 2018