!!!Warning!!! ------------- For experts in FPU coding ONLY! ;) Hi, I'm writing a demo where a 3D Cube rotates and a fire burns below it. The fire works fine, but there is a bug in the the Cube rotation and/or coordinate calculations. It's my first time I've coded the FPU in Asm and I don't know where the error is. To see at least the fire animation without a crash at the first frame of the demo, you should comment out the "invoke PutCube3D, 244, addr Buffer" line in the WinMain proc. I'm asking for help, please!!! Help me to find the bug! I will credit whoever helps me with this problem!!! I have done this kind of calculations some times in C and one time in a demo using VC++ and it worked fine. The demo that I'm writing in Win32asm is a EXACTLY rewrite of my VC++ version of this demo. Maybe, before you look at the Win32Asm source, you should take a look at the VC++ version of the demo. Win32asm demo source VC++ demo source Thanks to everyone who will try to help me. This message was edited by eeprom, on 4/23/2001 8:36:06 PM
Posted on 2001-04-23 20:33:00 by eeprom
I was about to check it out, but i dont have 'ddraw.inc'. So i cant help you much... :rolleyes: NaN
Posted on 2001-04-23 22:45:00 by NaN
"ddraw.inc" comes with the MASM32 packet. I recommend you to download it because a lot of Win32Asm proggs use the INC's included in that packet.
Posted on 2001-04-24 21:51:00 by eeprom
I cannot assemble your code, because I'm one of the rare WATCOM assembler users, but your code is missing some pop commands during FPU access. If you load data inside FPU (fld) you must take care of the available 8 FPU stack slots. After a calculation you should use fstp instead of fst. example:

fld CubeZ	;st(0)= CubeZ
fmul SinY		;st(0)= SinY*CubeZ
fld CubeX	;st(0)= CubeX		;st(1)=SinY*CubeZ
fmul CosY		;st(0)= CosY*CubeX	;st(1)=SinY*CubeZ
fsub st, st(1)	;st(0)= (CosY*CubeX)-(SinY*CubeZ)
fst TempX		;TempX = (CosY*CubeX)-(SinY*CubeZ)
now st(1) and st(0) is used and not free-ed. you can now use ffree st(1) and ffree st(0) or you write

fstp TempX
fstp Dummy
Hope I'm understandable :D beaster.
Posted on 2001-04-25 11:37:00 by beaster
Hm... it doesn't worked. I don't know, but I think that the number of times that I "fld" without a "fstp" is not the problem. I think that if you "fld" a value, st(6) will move to st(7), and st(7) will be eliminated. Just like a "shr" where the right-most bit is eliminated and it's space is occupiced by the bit wich was at it's left. If the FPU doesn't work this way, how does it should work then? Can there be a FLD overflow after 7 "fld" without a "fstp"? What happens with st(7) after a "FLD"?
Posted on 2001-04-25 21:36:00 by eeprom