Author Topic: I have confusions regarding 64-bit push  (Read 5753 times)

Offline stressful

  • Full Member
  • **
  • Posts: 105
  • Country: 00
    • CPU2.0
I have confusions regarding 64-bit push
« on: November 04, 2014, 08:53:44 PM »
Hi. Could somebody explain to me why I can't push a qword precision constant into a stack?

Code: [Select]
push qword 34.5 ;fail
call something

But this one works...
Code: [Select]
mov rax,34.5
push rax
call something

Why do I have to put them into a register first? Similarly, I can push a qword integer constant directly without any problem.

Thanks.


Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2596
  • Country: us
Re: I have confusions regarding 64-bit push
« Reply #1 on: November 04, 2014, 10:51:59 PM »
I'm not very familiar with 64-bit code, but I consider it decidedly "weird". I suspect that your "qword integer constant" actually fits into a dword, and that's why it works(?). If putting your "double" into a register works, I'd just "go along with it" for now...

Best,
Frank


Offline stressful

  • Full Member
  • **
  • Posts: 105
  • Country: 00
    • CPU2.0
Re: I have confusions regarding 64-bit push
« Reply #2 on: November 05, 2014, 02:52:22 AM »
If putting your "double" into a register works, I'd just "go along with it" for now...
Best,
Frank

 ok ;D

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 430
  • Country: us
Re: I have confusions regarding 64-bit push
« Reply #3 on: November 05, 2014, 03:05:59 PM »
Why do I have to put them into a register first? Similarly, I can push a qword integer constant directly without any problem.

There are no opcodes in x64 that enable direct qword constant to memory, thus you can neither push, nor mov, an immediate qword.  I personally don't understand the reasoning for the inability to do this by the chip makers, maybe someone from Intel or AMD can chime in here, but it is what it is.