www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Translating inline ASM from C++

reply Etienne <etcimon gmail.com> writes:
I'm translating some library from C++ and I'd need some help with 
assembler translations. I've read the guides on D inline assembler but 
it's fairly thin. I don't understand what "=r", "=a", "%0", "%1" should 
be in D. Is this some sort of register?

https://github.com/etcimon/botan/blob/master/source/botan/entropy/hres_timer.d#L107

I currently only need to translate these commented statements. If anyone 
could donate some code for it I'd be grateful, and it would help us all 
move towards a completely native crypto/ssl library ;)
Oct 15 2014
parent reply Etienne Cimon <etcimon gmail.com> writes:
On 2014-10-15 09:48, Etienne wrote:
 I currently only need to translate these commented statements. If anyone
I found the most useful information here in case anyone is wondering: http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html The D syntax for inline assembly is Intel style, whereas the GCC syntax is AT&T style. This guide seems to show exactly how to translate from C++ to D.
Oct 15 2014
parent Etienne Cimon <etcimon gmail.com> writes:
On 2014-10-15 19:47, Etienne Cimon wrote:
 The D syntax for inline assembly is Intel style, whereas the GCC syntax
 is AT&T style. This guide seems to show exactly how to translate from
 C++ to D.
I'm posting this research for anyone searching the forums for a solution. I found a better guide to D assembly on the digitalmars website: http://www.digitalmars.com/ctg/ctgInlineAsm.html This says it emulates Borland Turbo Assembly. Here's a manual I found: http://www.csn.ul.ie/~darkstar/assembler/manual/ Chapter 6 is the most interesting: http://www.csn.ul.ie/~darkstar/assembler/manual/a06a.txt Also, this works in DMD but also compatible with LDC and GDC, they all support the D inline assembler syntax for x86 and x86_64 : https://github.com/ldc-developers/ldc/blob/master/gen/asm-x86.h
Oct 15 2014