I need to divide a float in let's say st0 by an integer (in this example 2): So know that i can achieve this by simply:
mov rax, 2
fild rax
fdivp st1
but is there a more elegant and less bulky version like (and I know the following doesn't work):
fidiv 2
:S please let me know too if it's impossible :) thanks in advance
None of the x87 instructions support immediate values. What you need to do is store the constant you want to divide by in some memory location and then load it implicitly using a memory operand:
fdiv DWORD PTR two ; st0 = st0 / 2
...
two REAL4 2.0
Note that division by constants can be sped up massively by multiplying with the reciprocal instead:
fmul DWORD PTR two ; st0 = st0 * 0.5 = st0 / 2
...
two REAL4 0.5