Author Topic: Help with setting 64 bit immediates with MOV  (Read 16631 times)

nobody

  • Guest
Help with setting 64 bit immediates with MOV
« on: September 18, 2007, 10:43:18 PM »
I am debugging some X64 code I assembled with NASM and I am getting odd results when setting a 64bit immediate value to a 64bit register.

When I'm using the following instruction:  

mov rax, 08080808080808080h

I'm expecting rax to have the hex value of 0x08080808080808080, However it appears that NASM is truncating the value to 4 bytes and then sign extending it, so I get the following value instead assigned to rax:

0xFFFFFFFF80808080

Is there some special syntax I'm missing? Any help would be greatly appreciated.

Chris

(If the helps I'm assembling with the '-t -f elf64' options and the CPU directive is set to X64)

nobody

  • Guest
Re: Help with setting 64 bit immediates with MOV
« Reply #1 on: September 19, 2007, 12:50:06 AM »
hello,
try that: mov rax,qword 08080808080808080h
@++

nobody

  • Guest
Re: Help with setting 64 bit immediates with MOV
« Reply #2 on: September 19, 2007, 01:00:11 AM »
I've already tried that and I get the same problem

Chris

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Help with setting 64 bit immediates with MOV
« Reply #3 on: September 19, 2007, 05:03:02 AM »
I was going to ask what version of Nasm you're using (it's quite volatile, these days), and assure you that it *does* work with the latest release 0.99.02... but it works in "-f bin", but *not* in "-f elf64"!!!

Oh, oh! Stop the presses!

Thanks for the feedback, Chris!

Best,
Frank