flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
me239
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!
|
|||
![]() |
|
macgub
The same code done on FPU:
Code: fninit fld dword[esp+4] ; single precision, 32 bits. fadd dword[esp+8] ; st0 - result |
|||
![]() |
|
Akujin
Internals of FPU and MA$M examples.
http://www.ray.masmcode.com/downloads/SimplyFPU1-6.zip _________________ CLI HLT |
|||
![]() |
|
edfed
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. |
|||
![]() |
|
me239
edfed wrote: simple example: now how would I print one of those values to the prompt? |
|||
![]() |
|
emc
You can use printf with a formatted string (with %f) to print floating values.
|
|||
![]() |
|
me239
emc wrote: You can use printf with a formatted string (with %f) to print floating values. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.