NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on April 03, 2009, 02:52:13 PM
-
Hi,
First time caller here.
I have the following code in my test asm program:
movntq [EDI ], mm1;
When I trying debug however, movntq does not appear to be used but another set of instructions is instead inserted in its place.
I'm using NASM version 2.06rc1.
Is this correct?
-
Please post your list file (nasm -l x.lst x.asm), so that we can see the resulting opcodes.
Are you sure that you're using the same mode both, at assembly time (NASM) and run-time (debugger)?
For example, you're not assembling this MOVNTQ in 16-bit mode, but then running it in 32-bit mode, right?
-
I do not think i'm running in a different mode but I may be wrong.
Let me explain what I have done. Firstly I have created an assembly file containing the following:
global TestMovntq;
export TestMovntq;
segment code public use32 class=CODE
..start:
dllstart:
mov eax, 1;
ret 12 ;
TestMovntq:
push ebp;
mov ebp, esp;
; load parameters
mov esi, [ebp+12]; second argument in call (source)
mov edi, [ebp+8];
movq mm0, [esi];
movntq [edi], mm0;
emms;
pop ebp;
ret 8;
Now this builds with nasm -fobj -l TestMovntq1.lst TestMovntq1.Asm
and links with alink -oPE -dll TestMovntq1.
THis all builds and links with no errors. I subsequently load the dll at runtime in a Borland c++ application and call the function TestMovntq(__int64 *Src, __int64 *Dest);
The Src is successfuly copied to the dest but, when I look in Borlands debugger window I see the following:
push ebp
mov ebp,esp
mov esi,[ebp+0x0c]
mov edi,[ebp+0x08]
movq mm0,[esi]
db 2
pop es
emms
pop ebp
ret 0x0008
Is there something that I have fundamentally not understood? Or is this a bug?
Here is the contents of the lst file:
1 global TestMovntq;
2 export TestMovntq;
3
4 segment code public use32 class=CODE
5
6 ..start:
7 dllstart:
8 00000000 B801000000 mov eax, 1;
9 00000005 C20C00 ret 12 ;
10
11 TestMovntq:
12 00000008 55 push ebp;
13 00000009 89E5 mov ebp, esp;
14 ; load parameters
15 0000000B 8B750C mov esi, [ebp+12]; second argument in call (source)
16 0000000E 8B7D08 mov edi, [ebp+8];
17
18 00000011 0F6F06 movq mm0, [esi];
19 00000014 0FE707 movntq [edi], mm0;
20
21 00000017 0F77 emms;
22
23 00000019 5D pop ebp;
24
25 0000001A C20800 ret 8;
Thanks for any help
-
I think you've discovered a bug, alright, but in Borland's debugger, not Nasm. The Nasm output looks right to me. I don't know where the "db 2" came from - disassembling in 16-bit mode *does* turn up a "pop es"...
I don't think it's Nasm's problem. What's Ollydbg think about it?
Best,
Frank