Author Topic: FPU view of the fpu registers step by step  (Read 4822 times)

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
FPU view of the fpu registers step by step
« 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
Code: [Select]
;------------------ 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

  • Member
  • *****
  • Posts: 3517
  • Forgive your enemies, but never forget their names
Re: FPU view of the fpu registers step by step
« Reply #1 on: December 03, 2012, 08:55:48 PM »
Hi ToutEnMasm,

will your library work with other compilers, too?

Gunther
Get your facts first, and then you can distort them.

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: FPU view of the fpu registers step by step
« Reply #2 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.
Fa is a musical note to play with CL

Gunther

  • Member
  • *****
  • Posts: 3517
  • Forgive your enemies, but never forget their names
Re: FPU view of the fpu registers step by step
« Reply #3 on: December 03, 2012, 09:25:28 PM »
Thank you. So I'll give it a try and write some feedback after that.

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Member
  • *****
  • Posts: 7734
  • Assembler is fun ;-)
    • MasmBasic
Re: FPU view of the fpu registers step by step
« Reply #4 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...
Quote
include \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?

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: FPU view of the fpu registers step by step
« Reply #5 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.
Fa is a musical note to play with CL

dedndave

  • Member
  • *****
  • Posts: 8749
  • Still using Abacus 2.0
    • DednDave
Re: FPU view of the fpu registers step by step
« Reply #6 on: December 04, 2012, 03:52:55 AM »
Jochen,
maybe you need Yves' "ready-to-use" sdk to build it   :P

jj2007

  • Member
  • *****
  • Posts: 7734
  • Assembler is fun ;-)
    • MasmBasic
Re: FPU view of the fpu registers step by step
« Reply #7 on: December 04, 2012, 04:05:29 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

  • Member
  • *****
  • Posts: 8749
  • Still using Abacus 2.0
    • DednDave
Re: FPU view of the fpu registers step by step
« Reply #8 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

japheth

  • Guest
Re: FPU view of the fpu registers step by step
« Reply #9 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.