Nathan Osman
Nathan Osman

Reputation: 73215

How to move value from the stack to ST(0)?

I am having trouble believing the following code is the most efficient way to move a value from the stack to ST(0):

.data
var dd 4.2
tmp dd ?

.code
mov EAX, var
push EAX
; top of stack now contains a value

; move it to ST(0)
pop EAX
mov tmp, EAX
fld tmp

Is the temporary variable really necessary? Further, is there an easier way to get a value from the stack to ST(0)?

Update: In the example above, I'm moving floating-point values around - not integers.

Upvotes: 1

Views: 1896

Answers (1)

I. J. Kennedy
I. J. Kennedy

Reputation: 25819

fld dword ptr [esp]    ; assembles to D9 04 24

Upvotes: 3

Related Questions