3

I tried to compile the following code (test.asm):

section .text       
 global _WinMain@64       

_WinMain@64:       
    jmp _Begin

_End:
    mov esi, 0x77162c51    ;Address of 'WinExec' function
    call esi               ;Error(9)
    ret

_Begin:    
    xor eax, eax
    push eax               ;Error(14)
    call _End
    db "C:\WINDOWS\system32\calc.exe", 0

Here's the command I used :

nasm -f win64 test.asm -o test.o

And here's the following errors I have in output :

test.asm:9: error: instruction not supported in 64-bit mode
test.asm:14: error: instruction not supported in 64-bit mode

I used to code ASM program using MASM32 on the same architecture without any problem. I don't understand this error.

Thanks a lot in advance for your help.

MRS1367
  • 1,053
  • 1
  • 14
  • 40
user1364743
  • 5,283
  • 6
  • 51
  • 90
  • 2
    It isn't clear what the point might be in running this code in 64-bit mode. But yes, clearly the code is entirely invalid in that mode. A function address is 64-bit, not 32-bit so it has to be `call rsi` and stack moves have to be 64-bit as well so it has to be `push rax`. It surely compiled okay when you used MASM because you used the 32-bit version of it. Don't expect great things to happen when the call returns. – Hans Passant Dec 02 '13 at 14:10
  • Ok it's clear. Thank you for your help. Bye. – user1364743 Dec 02 '13 at 14:15

0 Answers0