Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NASM assembler - unwanted 66 in generated machine code

Tags:

x86

assembly

nasm

  • os:windows 10
  • cpu:intel core i5-5300U
  • architecture:x64

I just started to learn assembly language. I used the online compiler, but today I downloaded NASM. I tried to assemble this simple code that multiplies 10 by 15:

mov eax, 0xa
mov edx, 0xf
imul eax, edx
ret

An attempt to execute the machine code generated by NASM has failed so I opened this code in hex editor and compared it with code generated by online assembler that I can successfully execute.

NASM:

66 b8 0a 00 00 00 66 ba 0f 00 00 00 66 0f af c2 c3

online editor:

b8 0a 00 00 00 ba 0f 00 00 00 0f af c2 c3

The only differences between these two codes are the unwanted 66's in the code generated by NASM. Can anyone help me?

like image 354
Roman Kwaśniewski Avatar asked Oct 15 '22 16:10

Roman Kwaśniewski


1 Answers

It is as Jester suggested. I do not included BITS 64 declaration. Now when I included BITS 64 everything works

like image 143
Roman Kwaśniewski Avatar answered Nov 14 '22 22:11

Roman Kwaśniewski