0

Now I'm working with floating point numbers IEEE 754 (single precision) and I wonder if I can somehow extract the parts of the floating point value to 64 bits registers (rax, rbx, rcx for example)

I'm using nasm so I've tried this code:

section .data
        num dq -5.24324
        num2 dq 1.53453

section .bss
        ans1 resb 8

section .text
        global _start

_start:
        fld qword [num]
        fxtract
        fst ans1 ; extracting the exponent
        mov rax, [ans1]
        jmp _exit

But I got error here: main.asm:16: error: invalid combination of opcode and operands What do I do wrong?

MindW1n
  • 11
  • 4
  • First of all, normally you'd want to use SSE2 for integer shifts on the FP bit pattern, or 64-bit integer registers in the first place. (Or AVX-512 [`vgetmantsd`](https://www.felixcloutier.com/x86/vgetmantsd) / `vgetexp` as in [vgetmantps vs andpd instructions for getting the mantissa of float](https://stackoverflow.com/q/52261067)). But the error message here is because memory operands need square brackets, like `fst qword [ans1]`, exactly like you're doing for `fld`. Exactly like if you'd written `mov ans1, rax` or `fld num`. – Peter Cordes Jan 08 '23 at 09:57

0 Answers0