The MASM Forum

Miscellaneous => Miscellaneous Projects => Windows Projects => Topic started by: TouEnMasm on December 03, 2012, 08:45:51 PM

Title: FPU view of the fpu registers step by step
Post by: TouEnMasm on December 03, 2012, 08:45:51 PM
The source code is just made of a callback function called by a library.
You have just to put your fpu code in it.
At each step you add,you can view what is changed in the FPU

;------------------ start test code here --------------
....
call Step
.....
;--------------------- end of test code --

The code use the vc++ msvcrt lib
A little change with the version in the old forum,is the use of the sprintf_s function instead of the StringCbPrintfEx.No need of the strsafe.lib now.

changing the line:
Quote
invoke SauvePile,Show_Float     
By another value,
Show_Float equ 0
Show_Hexa  equ 1
Show_Expo  equ 2
Show_Deci  equ 3

change the visual format of numbers.





Title: Re: FPU view of the fpu registers step by step
Post by: Gunther on December 03, 2012, 08:55:48 PM
Hi ToutEnMasm,

will your library work with other compilers, too?

Gunther
Title: Re: FPU view of the fpu registers step by step
Post by: TouEnMasm on December 03, 2012, 09:04:10 PM

I have not tested that ,but it is simple enough for that Jwasm or poasm can compile it.The library is already compile.
Title: Re: FPU view of the fpu registers step by step
Post by: Gunther on December 03, 2012, 09:25:28 PM
Thank you. So I'll give it a try and write some feedback after that.

Gunther
Title: Re: FPU view of the fpu registers step by step
Post by: jj2007 on December 03, 2012, 09:31:06 PM
It assembles fine, but the linker throws a hundred errors

libcmt.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
libcmt.lib(crtmboxw.obj) : error LNK2001: unresolved external symbol __imp__EncodePointer@4
libcmt.lib(winsig.obj) : error LNK2001: unresolved external symbol __imp__EncodePointer@4


etc etc...

With this snippet...
Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; download (http://masm32.com/board/index.php?topic=94.0)
.data
valeur   DQ 60.0
ONE_80   DT 180.0
Float   DQ 0   ;QWORD  8 bytes , Double-precision floating point

.code
Step:
deb 4, "FPU", ST(0), ST(1)   ;, ST(2)   ; you can add more regs or variables if needed
retn

  Init
  FLD valeur      ; valeur DQ 60.0 'dans trigo.asm ligne 215   
  call Step
  ;DEG_TO_RAD
  FLD     ONE_80
  call Step
  ;     180     |     d      |
  FLDPI           ;    pi       |    180     |     d     |
  call Step ; inspect the FPU
  FDIV    ST,ST(1);  pi/180     |    180     |     d     |
  call Step ; inspect the FPU
  FSTP    ST(1)   ;  pi/180     |     d      |
  call Step
  FMUL    ST,ST(1);     r       |     d      |
  call Step      
  FSTP    ST(1)   ;     r       |  --------- |      
  call Step
  ; fin de DEG_TO_RAD            
  FSIN
  call Step      
  FSTP Float  ;load Float with pop (FSTP) sans pop (FST)
  call Step
  Inkey Str$("The final result in 'Float' is %f", Float)
  Exit
end start
... I get the following output:
FPU
ST(0)           60.0000000000000000
ST(1)           0.0

FPU
ST(0)           180.000000000000000
ST(1)           60.0000000000000000

FPU
ST(0)           3.14159265358979324
ST(1)           180.000000000000000

FPU
ST(0)           0.0174532925199432958
ST(1)           180.000000000000000

FPU
ST(0)           0.0174532925199432958
ST(1)           60.0000000000000000

FPU
ST(0)           1.04719755119659775
ST(1)           60.0000000000000000

FPU
ST(0)           1.04719755119659775
ST(1)           0.0

FPU
ST(0)           0.866025403784438647
ST(1)           0.0

FPU
ST(0)           0.0
ST(1)           0.0
The final result in 'Float' is 4.605976e+18


Is that more or less the expected result?
Title: Re: FPU view of the fpu registers step by step
Post by: TouEnMasm on December 04, 2012, 12:34:27 AM

it is that ,after the result 0866...
There is a blank with Number of data = 0,indicating the fpu is returned to is initiate state.
Title: Re: FPU view of the fpu registers step by step
Post by: dedndave on December 04, 2012, 03:52:55 AM
Jochen,
maybe you need Yves' "ready-to-use" sdk to build it   :P
Title: Re: FPU view of the fpu registers step by step
Post by: jj2007 on December 04, 2012, 04:05:29 AM
Quote from: dedndave on December 04, 2012, 03:52:55 AM
Jochen,
maybe you need Yves' "ready-to-use" sdk to build it   :P

Dave,
Have you been able to build Yves' example? Anybody else?
Title: Re: FPU view of the fpu registers step by step
Post by: dedndave on December 04, 2012, 04:44:57 AM
i had his SDK set up on this machine, but i had to rebuild
i haven't "installed" it on here, yet
Title: Re: FPU view of the fpu registers step by step
Post by: japheth on December 04, 2012, 07:23:23 PM

IIRC, EncodePointer(ptr) and DecodePointer(ptr) are kernel32 functions, called by the more recent MSVC runtimes.

You probably just have to update your kernel32.lib.

> Have you been able to build Yves' example? Anybody else?

Yes.