AsmMathLib - A library of trigonometric functions for MikeOS

35 views
Skip to first unread message

Emanuel Cabrera

unread,
Dec 27, 2021, 1:46:20 PM12/27/21
to MikeOS

Hello everyone
I made a math library for MikeOS 4.6.1, with fixed point and sign. It is a simple library, which presents the four operations (addition, subtraction, multiplication and division), three trigonometric operations (sine, cosine and tangent) based on a table (as already discussed in this group, whether using the Taylor Series or another approximation of the engine, would require more processing and memory) and the constant PI (3.14).
In numerical representation, the following is used:
3.45 = 345/100
or
1.5 = 10/15
or
1,579 = 1579/1000
or
579 = 579/1
The numbers 100, 10, 1000 and 1 are equivalent to the scale factor of the respective numbers, allowing the calculation with a fixed point.
The sign follows the convention of 0 for positive and 1 for negative, making the calculation easier. Hope it's well used for calculations and stuff.

I think it's too heavy to add to a MikeOS version, so it can serve as an add-on to the programs.
Oh, and if you find any errors, or have any questions about it, send it to my other email (em74...@gmail.com).

 Emanuel

You can access the library here: https://github.com/Manolo789/AsmMathLib

Michael Saunders

unread,
Dec 28, 2021, 3:28:47 AM12/28/21
to Emanuel Cabrera, MikeOS
Hi Emanuel,

That looks great -- thanks for sending the link! It's well-documented
and easy to understand -- exactly what we need in MikeOS. I'm looking
at preparing a MikeOS 4.7 release with a bunch of changes that have
accumulated over the last year or so. We could include it, but if
you'd prefer it to be an optional extra, I could add it to the list of
add-on extras here:

http://mikeos.sourceforge.net/#downloads

What do you think?

Cheers,
Mike
> --
> You received this message because you are subscribed to the Google Groups "MikeOS" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mikeos+un...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/mikeos/ca6b44a7-d26c-4589-97ae-039f27ba5be5n%40googlegroups.com.

Emanuel Cabrera

unread,
Dec 28, 2021, 7:28:19 AM12/28/21
to MikeOS
Hello Michael

I think it's a good idea to put it in the additional extras section.
Glad you think the documentation is good, that's the goal.

Emanuel

Wojciech G

unread,
Dec 28, 2021, 9:55:42 AM12/28/21
to MikeOS
Hi, 
First of all, great work Emanuel! Code is well documented and easy to 
understand. That is exactly what this whole project is about, so it is 
always good to add comments.
Also, one thing with the library itself: maybe in pdiv, signal error with 
the carry flag (CF) instead of setting DX? This would make it more 
consistent with other syscalls/libraries in the project, and it would be 
much easier to check for an error in code (jc vs. test dx,dx \ jz).
Besides this, the library seems to be really well designed, with logical 
choices as for the API.

Wojtek.
PS Thanks for attaching a link to GitHub, it really saves some hassle!

Emanuel Cabrera

unread,
Dec 28, 2021, 4:03:57 PM12/28/21
to MikeOS
Hello Wojtek

A good idea to use the carry flag (CF) instead of the DX (in version 0.0.0-beta1 I will include this).
Before, I was in doubt as to whether or not to put it, because I thought that if we put the CF, it would interfere with the readability of the code.

Emanuel

Emanuel Cabrera

unread,
Dec 30, 2021, 2:08:40 PM12/30/21
to MikeOS
Hey guys.
I forgot to mention a detail. Probably, as the library doesn't have
external dependencies to work (BIOS calls, system calls, etc), it can
work without compatibility issues in MikeOS 4.7.

Emanuel
Reply all
Reply to author
Forward
0 new messages