1

NASM Assembly 64-bit

I'm fairly new to assembly. My question is how do I assign a value as a float to a variable?

C example:

float x;
x = 10.00;

I've looked around a bit but I haven't obtained a definite answer. All I've seen is constants being moved to xmm0.

ten: dw 10.00
x: resw 1

movsd xmm0, [ten]
movsd [x], xmm0

I'm sure there's a way to skip that hassle?

Edster
  • 21
  • 1
  • 4
    A float is a 32 bit value, you can `mov` it into memory directly as an immediate. See section [3.4.6 Floating-Point Constants](http://www.nasm.us/xdoc/2.11.08/html/nasmdoc3.html#section-3.4.6) in the manual. Example: `mov dword [ten], __float32__(10.00)` PS: you need a `dd` not a `dw`. – Jester Apr 30 '16 at 23:17
  • 1
    @Jester, that should be the answer.... – Johan Apr 30 '16 at 23:19
  • Yes, thank you @Jester – Edster Apr 30 '16 at 23:34

0 Answers0