0

i have to multiply a number with pi(3.141592) but can´t get it to work under SASM, as i can´t calculate with floating point numbers

I think i have to use hexadecimal numbers, but can’t figure out how to use them together with a floating point number.

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
User342
  • 17
  • I ´ve basicaly only saved the hex number of pi in the register ax, with the command mov ax, 2FEFD8 .But now i saved it without any point in between so i don ´t know how to go on – User342 Nov 06 '22 at 16:46
  • 1
    you still need to show what you've tried. Include the code you've written, where you got stuck and **tag the appropriate architecture** – phuclv Nov 06 '22 at 16:56
  • It´s for school so im only doing the method for the multiplication and not programming the whole code, that would be what i thought of so far(ax is a given entry to be multiplied by dx(pi): mul_pi: ;Start mov dx, 0x2fefd8 ;pi=3(.)141592 imul ax,dx ;End ret – User342 Nov 06 '22 at 17:41
  • Architecture is x86 working on Sasm on linux – User342 Nov 06 '22 at 17:51
  • 1
    If you want **floating**-point, you should use XMM registers like `movsd xmm0, [something]` / `mulsd xmm0, [pi]`. (Where `pi` is `pi: dq 3.141592653589793` in `section .rodata`). Or legacy x87 `fldpi` / `fmulp` if you're taking a course that wants you to use the mostly-obsolete x87 FPU. Normally you'd only want integer `imul` for fixed-point. – Peter Cordes Nov 06 '22 at 22:37
  • Possibly related to this older question? https://stackoverflow.com/questions/64971760/how-would-the-mul-operation-on-ax-with-pi-3-1415-in-8-8-format-work-in-ass – Michael Petch Nov 07 '22 at 01:37

0 Answers0