I have a real8 number and I want to save it right into the stack, how would I do that???

I know it's possible, it's like increasing the stack pointer and saving into it, but my memory fails me right now, how? I don't want to save it into memory and then push it into the stack because that takes to long...
Posted on 2001-11-02 14:31:44 by Kenny
fld R?RealNumber
sub esp 8
fstp R?esp

Betov.
Posted on 2001-11-05 10:42:52 by Betov
yeah, I figured that out about 2 days ago :)

I should have answered my own question :) hehe What threw me off is that I had used 'enter' and 'leave' and I was getting ebp and esp confused, so I was screwing up my program so bad I was reting to some unknown place (exceptions galore)
Posted on 2001-11-05 11:09:45 by Kenny
I wrote an MASM macro for this, will post later...(doesn't use FPU :))
movr8 MACRO memloc:REQ, val:REQ

db 0C7h, 05h ;C7 05^
dd offset memloc ;C7 05 rr rr rr rr^
db 0,0,0,0,0,0 ;C7 05 rr rr rr rr 00 00 00 00 00 00^
dd offset memloc+4 ;C7 05 rr rr rr rr 00 00 00 00 00 00 rr rr rr r4^
org $-10 ;C7 05 rr rr rr rr^00 00 00 00 00 00 rr rr rr r4
REAL8 val ;C7 05 rr rr rr rr 01 23 45 67 89 AB CD EF^
org $-4 ;C7 05 rr rr rr rr 01 23 45 67^89 AB CD EF
db 0C7h, 05h ;C7 05 rr rr rr rr 01 23 45 67 C7 05^CD EF
REAL8 val ;C7 05 rr rr rr rr 01 23 45 67 C7 05 01 23 45 67 89 AB CD EF^
org $-8 ;C7 05 rr rr rr rr 01 23 45 67 C7 05^01 23 45 67 89 AB CD EF
dd offset memloc+4 ;C7 05 rr rr rr rr 01 23 45 67 C7 05 rr rr rr r4^89 AB CD EF
org $+4 ;C7 05 rr rr rr rr 01 23 45 67 C7 05 rr rr rr r4 89 AB CD EF^
ENDM
There is an explaination of how and why this works at the old board, but I could explain again if you want.
Similar methods could be used to create other macros for REAL8 values. For push it'd be something like:
pushr8 MACRO val:REQ

db 068h ; push
db 0,0,0,0
REAL8 val
org $-12
REAL8 val
org $-4
nop ; you can replace these with something useful?
nop
nop
db 068h ; push
org $+4
ENDM
Edit:Woops, those DWORDS are backwards...try this:
pushr8 MACRO val:REQ

REAL8 val
db 068h ; push
REAL8 val
org $-(8+1+8)
nop ; you can replace these with something useful?
nop
nop
db 068h ; push
org $+4+1+4
nop ; you can replace these with something useful?
nop ; MASM has problems with relocating addresses
nop ; here. Best leave these in. :)
ENDM
Posted on 2001-11-05 21:09:50 by bitRAKE