digitalmars.D - Inline ASM in D
- Trevor (19/19) Mar 16 2005 OK, I gave up on getting NASM to work with DMD for now. I think it's my ...
- Carlos Santander B. (4/32) Mar 16 2005 Make sure your asm block is inside a function.
- Trevor (6/38) Mar 16 2005 What function do i put it in... I tride it in it's own, and also in the
- J C Calvarese (10/16) Mar 16 2005 If you haven't seen http://www.prowiki.org/wiki4d/wiki.cgi?KernelWithD
- Walter (5/9) Mar 16 2005 using the
- Walter (4/17) Mar 16 2005 own
- Sascha Katzner (15/16) Apr 27 2008 Is there any chance that you re-(think/work) this in the future?
- Frits van Bommel (13/31) Apr 27 2008 That would be why both Phobos and Tango have "uint bswap(uint)" (Phobos
- Sascha Katzner (6/10) Apr 27 2008 Nice, I've completely overlooked this module until now, thanks! :-)
- BCS (7/21) Apr 27 2008 one option would be to have a "mixin function" that would be used someth...
- Ilya Minkov (5/7) Mar 17 2005 No, it's probably not.
OK, I gave up on getting NASM to work with DMD for now. I think it's my own fault, but I am trying something else now. Inline assebler. I have the ASM code in a asm { .. asm code here ... } at the top of my kernel.d file. Is the what I should do to use the inline assembler instead of compiling the ASM code and linking seperate. will this work for a kernel? Right now i get errors. dmd -c Source\Kernel.d -odObjects\ Source\Core.d(6): Declaration expected, not 'asm' It was giving me errors when i used ; comment lines too... Any help as to how I can get this working, would be very much appriciated. This forum has been helpful thus far. Thanks again, Trevor Parscal www.trevorparscal.com
Mar 16 2005
Trevor wrote:OK, I gave up on getting NASM to work with DMD for now. I think it's my own fault, but I am trying something else now. Inline assebler. I have the ASM code in a asm { ... asm code here ... } at the top of my kernel.d file. Is the what I should do to use the inline assembler instead of compiling the ASM code and linking seperate. will this work for a kernel? Right now i get errors. dmd -c Source\Kernel.d -odObjects\ Source\Core.d(6): Declaration expected, not 'asm' It was giving me errors when i used ; comment lines too... Any help as to how I can get this working, would be very much appriciated. This forum has been helpful thus far. Thanks again, Trevor Parscal www.trevorparscal.comMake sure your asm block is inside a function. _______________________ Carlos Santander Bernal
Mar 16 2005
In article <d1ad2r$2aer$1 digitaldaemon.com>, Carlos Santander B. says...Trevor wrote:What function do i put it in... I tride it in it's own, and also in the kernel_main() but dmd seems to complain allot about x86 asm. I am just using the standard multiboot header stuff for grub. Thanks Trevor ParscalOK, I gave up on getting NASM to work with DMD for now. I think it's my own fault, but I am trying something else now. Inline assebler. I have the ASM code in a asm { ... asm code here ... } at the top of my kernel.d file. Is the what I should do to use the inline assembler instead of compiling the ASM code and linking seperate. will this work for a kernel? Right now i get errors. dmd -c Source\Kernel.d -odObjects\ Source\Core.d(6): Declaration expected, not 'asm' It was giving me errors when i used ; comment lines too... Any help as to how I can get this working, would be very much appriciated. This forum has been helpful thus far. Thanks again, Trevor Parscal www.trevorparscal.comMake sure your asm block is inside a function. _______________________ Carlos Santander Bernal
Mar 16 2005
Trevor wrote: ...What function do i put it in... I tride it in it's own, and also in the kernel_main() but dmd seems to complain allot about x86 asm. I am just using the standard multiboot header stuff for grub. Thanks Trevor ParscalIf you haven't seen http://www.prowiki.org/wiki4d/wiki.cgi?KernelWithD yet, I'd recommend you check it out. Several people have looked into creating a kernel with D before. It might help you out. (As mentioned in http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/19480) -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Mar 16 2005
"Trevor" <Trevor_member pathlink.com> wrote in message news:d1aetn$2c7h$1 digitaldaemon.com...using theMake sure your asm block is inside a function.What function do i put it in... I tride it in it's own, and also in the kernel_main() but dmd seems to complain allot about x86 asm. I am juststandard multiboot header stuff for grub.Look at the library functions in \dmd\src\phobos\std\math.d for some examples of inline assembler.
Mar 16 2005
"Trevor" <Trevor_member pathlink.com> wrote in message news:d1aaic$27sd$1 digitaldaemon.com...OK, I gave up on getting NASM to work with DMD for now. I think it's myownfault, but I am trying something else now. Inline assebler. I have the ASM code in a asm { .. asm code here ... } at the top of my kernel.d file. Is the what I should do to use the inline assembler instead of compiling the ASM code and linking seperate. will this work for a kernel? Right now i get errors. dmd -c Source\Kernel.d -odObjects\ Source\Core.d(6): Declaration expected, not 'asm'Inline assembler can only appear within functions.
Mar 16 2005
Walter wrote:Inline assembler can only appear within functions.Is there any chance that you re-(think/work) this in the future? I've just written: uint reverseUint(void* source) { asm { naked; mov EAX, [EAX]; bswap EAX; ret; } } ...and it strike me, that it would be *really* nice if the compiler would inline functions like that, either manually or automatically. LLAP, Sascha
Apr 27 2008
Sascha Katzner wrote:Walter wrote:That would be why both Phobos and Tango have "uint bswap(uint)" (Phobos in std.intrinsic, Tango in tango.core.BitManip). It's a compiler intrinsic, meaning it should compile down to the 'bswap' asm instruction on x86. And it does, at least on DMD. Unfortunately GDC appears to only provide a portable implementation with bitwise operators, not using the raw instruction. Though on GDC it *should* be possible to get the same effect by using the "Extended Assembler" syntax, which according to the documentation[1] doesn't prevent inlining. [1]: See <http://dgcc.sourceforge.net/gdc/manual.html>, about halfway through.Inline assembler can only appear within functions.Is there any chance that you re-(think/work) this in the future? I've just written: uint reverseUint(void* source) { asm { naked; mov EAX, [EAX]; bswap EAX; ret; } } ...and it strike me, that it would be *really* nice if the compiler would inline functions like that, either manually or automatically.
Apr 27 2008
Frits van Bommel wrote:That would be why both Phobos and Tango have "uint bswap(uint)" (Phobos in std.intrinsic, Tango in tango.core.BitManip). It's a compiler intrinsic, meaning it should compile down to the 'bswap' asm instruction on x86.Nice, I've completely overlooked this module until now, thanks! :-) ...but nevertheless I'm missing a way to build inline asm functions by myself. There are *A LOT* intrinsics that I'm missing. LLAP, Sascha
Apr 27 2008
Reply to Sascha,Frits van Bommel wrote:one option would be to have a "mixin function" that would be used something like this: mixin(SomthingInASM!(op1.stringof,op2.stringof))); it would expand to a sting with some static type checking if's and a block of asm. not clean but it would work.That would be why both Phobos and Tango have "uint bswap(uint)" (Phobos in std.intrinsic, Tango in tango.core.BitManip). It's a compiler intrinsic, meaning it should compile down to the 'bswap' asm instruction on x86.Nice, I've completely overlooked this module until now, thanks! :-) ...but nevertheless I'm missing a way to build inline asm functions by myself. There are *A LOT* intrinsics that I'm missing. LLAP, Sascha
Apr 27 2008
Trevor wrote:OK, I gave up on getting NASM to work with DMD for now. I think it's my own fault, but I am trying something else now.No, it's probably not. Consult this here: http://www.digitalmars.com/drn-bin/wwwnews?D/13150 -eye
Mar 17 2005