Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get a int from my EAX/RAX to a register of the FPU like st0?

I am currently working on a small Assembler project in University. Now my question is, is it possible to get a skalar for a multiplication (int), which is given by the user, from my EAX/RAX Register to one of my FPU register like st0? I am using NASM Syntax.

Thank you

like image 312
J.B. Avatar asked Jan 02 '23 10:01

J.B.


1 Answers

There is no way to directly transfer the content of an integer register to an x87 floating point register, you have to go through the memory. Typical code looks like this:

PUSH RAX         ; push RAX on the stack
FILD QWORD [RSP] ; load eight byte integer onto FP stack
ADD RSP,8        ; release storage from stack

You can usually avoid having to fiddle around with the stack pointer by allocating some storage for this sort of transfer in your stack frame at the beginning of your function.

like image 155
fuz Avatar answered Jan 13 '23 12:01

fuz