D - Dernel: Inline Assembler question
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (44/44) Feb 24 2004 Hi, I have the following code:
- Walter (5/8) Feb 24 2004 Because register contents are only tracked when using mnemonics, not whe...
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (7/10) Feb 24 2004 Hi, you mean in the first case the assembler assumes all registers are
- Walter (4/10) Feb 24 2004 when
Hi, I have the following code: asm { mov EDX, port; mov EAX, v; db 0xEE; // out DX, AL; } Which translates to: enter 4,0 push EBX push ESI push EDI mov -4[EBP],EAX mov EDX,8[EBP] mov EAX,-4[EBP] out DX,AL pop EDI pop ESI pop EBX leave ret 4 And I tried: asm { mov EDX, port; mov EAX, v; out DX, AL; } Which translates to: enter 4,0 mov -4[EBP],EAX mov EDX,8[EBP] mov EAX,-4[EBP] out DX,AL leave ret 4 nop nop 0xEE is the one-byte opcode for "out DX, AL". Why this difference in the generated code? Why does the first version, safes and restors the listed registers? Is this necessary or does the 2nd version work as well? -- Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
Feb 24 2004
"Robert M. Münch" <robert.muench robertmuench.de> wrote in message news:opr3v41vfqheztw6 news.digitalmars.com...0xEE is the one-byte opcode for "out DX, AL". Why this difference in the generated code? Why does the first version, safes and restors the listed registers? Is this necessary or does the 2nd version work as well?Because register contents are only tracked when using mnemonics, not when writing arbitrary hex bytes. In the latter case, the assembler assumes all registers are modified.
Feb 24 2004
On Tue, 24 Feb 2004 12:55:17 -0800, Walter <walter digitalmars.com> wrote:Because register contents are only tracked when using mnemonics, not when writing arbitrary hex bytes. In the latter case, the assembler assumes all registers are modified.Hi, you mean in the first case the assembler assumes all registers are modified and that's why these are safed and restored, right? -- Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
Feb 24 2004
"Robert M. Münch" <robert.muench robertmuench.de> wrote in message news:opr3v7vidjheztw6 news.digitalmars.com...On Tue, 24 Feb 2004 12:55:17 -0800, Walter <walter digitalmars.com> wrote:whenBecause register contents are only tracked when using mnemonics, notYes. You can also use 'naked' and handle the register save/restore manually.writing arbitrary hex bytes. In the latter case, the assembler assumes all registers are modified.Hi, you mean in the first case the assembler assumes all registers are modified and that's why these are safed and restored, right?
Feb 24 2004