Author Topic: Problem with x64 program  (Read 12049 times)

Offline namespace

  • New Member
  • Posts: 1
Problem with x64 program
« on: January 11, 2012, 10:22:27 PM »
Hello!

I'm beginner in nasm.
I have a x86 program:
Code: [Select]
   
global main
extern printf

    section .data
fmt:  db "a=%e",10,0
a:    dq 0x1.1p+32

   section .text

main:
   push dword [a+4]
   push dword [a]
   push  dword fmt
   call printf
   add esp,12
   ret

When I tried to compile on x64 NASM i have got a problem:
Code: [Select]
prog.asm:11: error: instruction not supported in 64-bit mode
prog.asm:12: error: instruction not supported in 64-bit mode

Does anyone know what I have to change in this program to compile on x64?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Problem with x64 program
« Reply #1 on: January 11, 2012, 11:09:58 PM »
Well, "push qword"... but you probably don't want to do that. They've changed the game! Take a look here:

http://www.vikaskumar.org/amd64/index.htm

Or the NASMX package might help you out...

I'm still running 32-bit hardware, so I can't help you much...

Best,
Frank


Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: Problem with x64 program
« Reply #2 on: January 12, 2012, 12:18:39 AM »
Jeremy Gordon, the author of GoAsm, has a pretty decent summary of Writing 64-bit programs with emphasis on low-level details.

However, if you are merely trying to assemble/run a 32-bit program on 64-bit Windows, then use -f win32 instead of -f win64 and link accordingly.