i have a sum value stored in 开发者_开发技巧
fstp qword [ebx] ; Copy contents of st0 to space currently on top of the system stack
how do i divide it by an integer value that is stored in register edi?
i thought it was just
fdiv edi
but it says invalid combination of....blah blah blha
insight?
You can't. The FPU does not have access to the integer registers.
As Jens says in his answer, the FPU does not have any direct access to the integer registers. You will need to use scratch memory to make the transfer. This is one of the major disadvantages of the x87 FPU. Example code might look something like:
section .bss
fpscratch: resd 1
...
section .text
;other code goes here
MOV fpscratch, edi
FILD fpscratch
FDIV
(Note on the above code: it has not been tested, obviously, and I'm a little rusty on my assembly so there is probably something wrong with it, even though it's nice and short.)
精彩评论