I'm working with Intel x64 assembly, NASM compiler, trying to move the "0x4000000000000000" constant to memory, which in the ieee 754 standard double should be equal to 2.0.
The code I'm using is:
%define two 0x4000000000000000
section .text
foo:
push rbp
mov rbp, rsp
mov QWORD [rdi], two
pop rbp
ret
Compiling this throws
warning: signed dword immediate exceeds bounds.
When i print the value in C++ it shows "0" instead of "2".
I've already found a way of getting the right value, which is:
mov r9, 0x4000000000000000
mov [rdi], r9
But i would like to know if there is a way of achieving this without the use of a register.
by the way, im compiling the code with this script:
#!/bin/bash
nasm -f elf64 -g -F dwarf vvp_asm.asm -o vvp_asm.o
g++ -c -m64 -std=c++11 main.cpp -o main.o
g++ -o main -m64 vvp_asm.o main.o
There is no instruction
You could use
or
which is only 8 bytes (if that matters).