flat assembler
Message board for the users of flat assembler.
Index
> Main > Floating Point examples |
Author |
|
me239 13 Oct 2011, 22:35
Hey guys, I've been looking all over for some SIMPLE examples of floating point math done in assembly and printing it. Preferably 16 bit, thanks!
|
|||
13 Oct 2011, 22:35 |
|
macgub 18 Oct 2011, 10:05
The same code done on FPU:
Code: fninit fld dword[esp+4] ; single precision, 32 bits. fadd dword[esp+8] ; st0 - result |
|||
18 Oct 2011, 10:05 |
|
Akujin 18 Oct 2011, 19:25
Internals of FPU and MA$M examples.
http://www.ray.masmcode.com/downloads/SimplyFPU1-6.zip _________________ CLI HLT |
|||
18 Oct 2011, 19:25 |
|
edfed 18 Oct 2011, 21:08
simple example:
compute ebx=eax*1.32456 Code: example1: push dword 1.32456 eax ;preload in stack finit ;init the fpu fld [ss:esp+4] ;load float 1.32456 fimul [ss:esp] ;mul by eax value fistp [ss:esp+4] ;store in second pop pop eax eax ;pop two times, free the stack ret ;quit compute eax=eax*sin(eax*pi) Code: example2: push eax finit fldpi ;load pi value fimul [ss:esp] ;mul by eax fsin ;sinus of st0 in st0 fimul [ss:esp] fistp [ss:esp] pop eax ret the fpu is simple in fact. |
|||
18 Oct 2011, 21:08 |
|
me239 19 Oct 2011, 03:51
edfed wrote: simple example: now how would I print one of those values to the prompt? |
|||
19 Oct 2011, 03:51 |
|
emc 22 Oct 2011, 06:49
You can use printf with a formatted string (with %f) to print floating values.
|
|||
22 Oct 2011, 06:49 |
|
me239 22 Oct 2011, 23:16
emc wrote: You can use printf with a formatted string (with %f) to print floating values. |
|||
22 Oct 2011, 23:16 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.