flat assembler
Message board for the users of flat assembler.
Index
> Main > FPU to and from ASCII |
Author |
|
farrier 22 Sep 2005, 02:15
eiforall,
You can use Raymond's excellent FPULIB which can found here: http://www.ray.masmcode.com/ It's coded in MASM, but with Vortex's tools, you can use the .lib file. In the FPULIB you will find FpuFLtoA and FpuAtoFL hth, farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
22 Sep 2005, 02:15 |
|
Vasilev Vjacheslav 22 Sep 2005, 05:34
it's not necessarily to create lib, because fpulib is open-source
|
|||
22 Sep 2005, 05:34 |
|
Octavio 22 Sep 2005, 11:01
farrier wrote: eiforall, The algorithms used have a lost of precision up to 12 bits for extreme numbers like 1.0e4000 There is a better algo that use a table of powers of 10 ,i don´t have links,but remember that some time ago it was posted on this forum. |
|||
22 Sep 2005, 11:01 |
|
shoorick 22 Sep 2005, 13:08
maybe somebody will need - inside the package function converting ascii string into the float in st0. i had look in masm lib on similar, but decided to write by myself as i like do not run exe directly! it made for test and have int3 to stop debugger to see what a number we have in st0!
regards!
_________________ UNICODE forever! Last edited by shoorick on 23 Sep 2005, 05:56; edited 1 time in total |
|||||||||||
22 Sep 2005, 13:08 |
|
eiforall 22 Sep 2005, 15:58
Thank you very much!
Now I am trying to port FPULIB to Fasm. Well always some little things. First it has uID feature witch make it covert form memory or fpu. Some macros like .if .endif … I am just surprised no one done clean float point conversions in fasm. Sorry shoorick I tried your program using Microsoft debugger and it showed that the register was something other then 12.1, which I typed. On second try Microsoft goofed up and started 2 debuggers and they where competing 45% of cpu on one and 45% of cpu on the other my mouse when jerky till I realized that they where running in the back ground windowless. Please make a ‘to and form’ converter then one can see how it is done without so much trouble. Which debugger did you use? |
|||
22 Sep 2005, 15:58 |
|
eiforall 22 Sep 2005, 18:28
Hi!
Look at: http://board.flatassembler.net/topic.php?t=234 I guess I could have gotten it there in the first place. I changed the code a little bit do reduce rigid syntax. Can enter – 123.23 instead of always –123.23 (now ignores spaces before and after sign instead of giving 0) But I still cant enter –12.23e34 … the E! Does any one know how to do make an fexp command? I mean take st(1)^st(0)? So I also find some student’s homework exponential project. Does any one have any ideas how I can check which one would be best? I need to measure size and speed of the code. Any more float point to/form ASCII are welcome since I sort of collect them now |
|||
22 Sep 2005, 18:28 |
|
Eoin 22 Sep 2005, 18:56
Here are two methods for raising 2^st(0), its MASM code but should be easy to convert. The first is probably the faster (credits to bitRAKE for it).
Code: fPow2 MACRO ; 2^st, 98 clocks sub esp,16 fist dword ptr [esp+12] fld1 fstp tbyte ptr [esp] fisub dword ptr [esp+12] mov eax,[esp+12] add [esp+8],eax f2xm1 fld1 fadd fld tbyte ptr [esp] fmul add esp,16 EndM Code: fPow2 MACRO ; 2^st fld st frndint fsub st(1),st fld1 fscale fxch fstp st fxch f2xm1 fld1 fadd fmul EndM Using that you can implement the two following macroinstructios Code: fExp MACRO ; e^st, 99 clocks fldl2e fmul fPow2 EndM Code: fPow MACRO ; st^st(1), 200 clocks fyl2x fPow2 EndM Attached are numerous additional trigonmetric macroinstructions. Again all MASM, but easy to convert.
|
|||||||||||
22 Sep 2005, 18:56 |
|
shoorick 23 Sep 2005, 05:00
eiforall
i'm using olly. commonly this function was written in self-education and was not used in real: when it was compiled by masm fwait-s were inserted there automatically - i'll try to play with it again and translate comments |
|||
23 Sep 2005, 05:00 |
|
shoorick 23 Sep 2005, 05:58
look at the new version above - it is same just you can run it without debugger - sprintf used to exact output it into second edit. and has translated comments. regards!
|
|||
23 Sep 2005, 05:58 |
|
farrier 23 Sep 2005, 06:31
With Raymonds permission, here is the FPULIB in DLL form which can be used easily from the FASM. Also included are the files, other than source, I used to build the DLL. Download the full package and Help file from:
http://www.ray.masmcode.com/ Assemble command: _____________________________________________________________________________________________ ML.EXE /c /coff /Cp /nologo /I"$I" FPU.asm _____________________________________________________________________________________________ Link command: _____________________________________________________________________________________________ LINK.EXE /SUBSYSTEM:WINDOWS /RELEASE /DLL /DEF:FPU.def /LIBPATH:"$L" /OUT:"FPU.dll" FPU.obj _____________________________________________________________________________________________ In you import section include the following: library fpu, 'c:\Program Files\Radasm\masm\projects\fpu\fpu.dll' import fpu, \ FpuAtoFL, 'FpuAtoFL', \ FpuAdd, 'FpuAdd', \ FpuFLtoA, 'FpuFLtoA', \ FpuComp, 'FpuComp' for each function you want, or include them all. hth, farrier
_________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||||||||||
23 Sep 2005, 06:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.