I am looking at the fld instruction and it takes memory location.
fld myVar
I have an array
myVar REAL4 ?
what is the best way to load these values into the FPU?
thx!
correction I meant
myVar REAL4 4 DUP (-2.)
want to load these for values into fpu registers.
the fld only lets me do a memory location. Can I do indexed?
thx.
Hi gmmo1971,
sure. Load a CPU register with the start address of your array, load the first element into the FPU stack, adjust your pointer register (add 4) and load the next array element. That's all.
Gunther
A short example:myVar REAL4 1.0,2.0,3.0
result REAL4 ?
...
fld myVar[0*SIZEOF REAL4]
fld myVar[1*SIZEOF REAL4]
; ST(0) = 2.0 , ST(1) = 1.0
; for example: use register only
fmulp st(1),st ; st(1) = st(1)*st(0) = 1*2 -> pop stack
; st(0) = 1*2
; for example: use memory operand
fmul myVar[2*SIZEOF REAL4] ; st(0) = st(0)*myVar[2*SIZEOF REAL4] = 2*3
fstp result ; save result and pop stack
You may take a look in Intel's or AMD's documentation for further details.
> Can I do indexed?
Yes.
include \masm32\include\masm32rt.inc
.data
MyR4 REAL4 -2., -1.0, 0.0, 1.0
.code
start: mov esi, offset MyR4
xor ecx, ecx
.Repeat
fld REAL4 ptr [esi+REAL4*ecx]
inc ecx
.Until ecx>=(sizeof MyR4/REAL4)
inkey "ok"
exit
end start
you can also use
mov esi, offset MyR4
fld REAL4 ptr [esi]
fld REAL4 ptr [esi+4]
fld REAL4 ptr [esi+8]
fld REAL4 ptr [esi+12]
or
fld MyR4
fld MyR4+4
fld MyR4+8
fld MyR4+12