Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - 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 Oct 12 2004
"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? Oct 13 2004
|