flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
DJ Mauretto 31 Mar 2008, 17:43
Code: float Number_Float = 29.07103 ; long Number_Long ; /* 32 bit ? 64bit ? */ __asm { fld [Number_Float] fistp dword [Number_Long] /* 32bit */ } or fistp qword [Number_Long] /* 64bit */ |
|||
![]() |
|
White-spirit 31 Mar 2008, 17:47
Thanks, and in Fasm ? =)
|
|||
![]() |
|
DJ Mauretto 31 Mar 2008, 17:53
Code: Number_Float DD 29.07103 Number_Long DD ? fld [Number_Float] fistp [Number_Long] |
|||
![]() |
|
dap 31 Mar 2008, 17:57
White-spirit wrote: Otherwise, where can i have a "really readable" doc' about the FPU instructions, their operands, simple examples... http://www.website.masmforum.com/tutorials/fptute/index.html |
|||
![]() |
|
edfed 31 Mar 2008, 17:59
just to anticipate the Question/
Code: num_float dd ?? num_long dd 29 fild [num_long] fstp [num_float] it will convert a dword in float |
|||
![]() |
|
White-spirit 31 Mar 2008, 18:42
Thanks but all the codes don't work, I use a little 32 bits kernel written by me on a PC emulator called Bochs and i get this error message on Bochs : "math_abort: MS DOS compatibility FPU exception" .
|
|||
![]() |
|
DJ Mauretto 31 Mar 2008, 19:00
1) Try to insert FINIT instruction at start of FPU operation
2) Try in Real Hardware Do you Have a CPU with FPU ? I don't use emulator,if in real hardware run then is emulator problem |
|||
![]() |
|
edfed 31 Mar 2008, 19:05
to test this kind of code, only a dos code is enough.
org 100h ==> code.com it's largelly enough.. ![]() |
|||
![]() |
|
White-spirit 01 Apr 2008, 08:05
DJ Mauretto wrote: 1) Try to insert FINIT instruction at start of FPU operation Thanks all, FINIT is what i needed =) |
|||
![]() |
|
White-spirit 01 Apr 2008, 08:11
Here's my function for those who need it :
Code: public ftol long dd ? ftol: push ebp mov ebp, esp finit fld dword [ebp+8] fistp [long] mov eax,[long] pop ebp ret |
|||
![]() |
|
revolution 01 Apr 2008, 08:14
White-spirit wrote: Here's my function for those who need it : Code: public ftol ftol: push ebp mov ebp, esp finit fld dword [ebp+8] fistp dword [ebp+8] mov eax,[ebp+8] pop ebp ret Also you can eliminate the ebp usage: Code: public ftol ftol: finit fld dword [esp+4] fistp dword [esp+4] mov eax,[esp+4] ret |
|||
![]() |
|
White-spirit 01 Apr 2008, 11:44
Yeah thanks =)
|
|||
![]() |
|
Madis731 01 Apr 2008, 11:52
I couldn't resist
![]() Of course the first one doesn't compile because FASM doesn't allow movq r64,xmm. But its legal, so here it is: Code: mov rcx,2364.01 fastcall ftol,rcx ftol: movq xmm0,rcx cvtpd2dq xmm0,xmm0 movq rax,xmm0 ret Actually if you have your data in a memory location you can use a simple macro. Code: macro ftoa a { cvtpd2dq xmm0,dqword[a] movq qword[a],xmm0 } ftoa my_float align 16 my_float dq 1234.56 |
|||
![]() |
|
White-spirit 01 Apr 2008, 12:00
How to get , for example , the int value 0147 of the float number 29.0147 please ? :
Code: dec_val: finit fld dword [esp+4] fist dword [esp+4] fsub dword [esp+4] ;An instruction to transform 0.0147 to 147 fistp dword [esp+4] mov eax,[esp+4] ret 4 EDIT : Misled on the use of FABS , sorry , but how to do please ? thanks |
|||
![]() |
|
Madis731 01 Apr 2008, 12:12
This is not called the INT value, but the FRACTIONAL part:
http://enrico.phys.cmu.edu/QCDcluster/intel/vtune/reference/vc131.htm AND a manual: http://www.intel.com/design/pentiumii/manuals/243191.htm |
|||
![]() |
|
revolution 01 Apr 2008, 12:34
White-spirit wrote: How to get , for example , the int value 0147 of the float number 29.0147 please ? |
|||
![]() |
|
Madis731 01 Apr 2008, 12:44
Ah, sorry, Extract only takes out the exponent and this is not what you need.
Revolution is right => (29.0147-29)*10000=147 ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.