News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

FPU view of the fpu registers step by step

Started by TouEnMasm, December 03, 2012, 08:45:51 PM

Previous topic - Next topic

TouEnMasm

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.





Fa is a musical note to play with CL

Gunther

Hi ToutEnMasm,

will your library work with other compilers, too?

Gunther
You have to know the facts before you can distort them.

TouEnMasm


I have not tested that ,but it is simple enough for that Jwasm or poasm can compile it.The library is already compile.
Fa is a musical note to play with CL

Gunther

Thank you. So I'll give it a try and write some feedback after that.

Gunther
You have to know the facts before you can distort them.

jj2007

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
.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?

TouEnMasm


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.
Fa is a musical note to play with CL

dedndave

Jochen,
maybe you need Yves' "ready-to-use" sdk to build it   :P

jj2007

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?

dedndave

i had his SDK set up on this machine, but i had to rebuild
i haven't "installed" it on here, yet

japheth


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.