October 12, 2004 in-line assembly register usage | ||||
---|---|---|---|---|
| ||||
How does one go about writing inline assembly and inform the compiler about which registers are being used? To be more concrete about things, I hate using a third variable to swap two pointers -- I know about the XOR hack (it's my favorite programmer's test.) x86 has the xchg instruction, which is perfect for the job. With GCC, I can tell the compiler about the operands to xchgc: one has to be memory, the other register, the register is an output. How would I go about writing this code, bearing in mind that this might appear in the middle of a statement sequence (how do I tell DMC what registers I intend to use)? Or is this just not possible? -scooter |
October 13, 2004 Re: in-line assembly register usage | ||||
---|---|---|---|---|
| ||||
Posted in reply to Scott Michel | "Scott Michel" <scottm@aero.org> wrote in message news:ckhlr0$1kqg$1@digitaldaemon.com... > How does one go about writing inline assembly and inform the compiler about which registers are being used? To be more concrete about things, I hate using a third variable to swap two pointers -- I know about the XOR hack (it's my favorite programmer's test.) x86 has the xchg instruction, which is perfect for the job. With GCC, I can tell the compiler about the operands to xchgc: one has to be memory, the other register, the register is an output. > > How would I go about writing this code, bearing in mind that this might appear in the middle of a statement sequence (how do I tell DMC what registers I intend to use)? Or is this just not possible? You don't need to tell it. DMC's inline assembler can figure it out from the instructions. It's a lot easier to use than GCC's. |
Copyright © 1999-2021 by the D Language Foundation