Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: SirCmpwn on December 01, 2010, 06:20:41 pm

Title: Math
Post by: SirCmpwn on December 01, 2010, 06:20:41 pm
Hello,
Can we discuss methods of doing signed math in decimal, like TIOS does, in z80 assembly?
Title: Re: Math
Post by: AngelFish on December 01, 2010, 06:31:00 pm
You're addicted to calcs and omni when you have multiple links to this type of material bookmarked:

http://www.andreadrian.de/oldcpu/Z80_number_cruncher.html#mozTocId181827 (http://www.andreadrian.de/oldcpu/Z80_number_cruncher.html#mozTocId181827)

http://z80.info/index.html (http://z80.info/index.html) (scroll down)

http://www.programmers-corner.com/tutorial/31 (http://www.programmers-corner.com/tutorial/31)

That's what I have for the z80, let alone the ARM stuff.
Title: Re: Math
Post by: Munchor on December 01, 2010, 06:31:58 pm
SirCmpwn, you're starting to make the maths engine, like 1+1? I know that maths in Assembly is really difficult, so good luck!
Title: Re: Math
Post by: SirCmpwn on December 01, 2010, 06:32:53 pm
Not yet, but I'm reading up.
Title: Re: Math
Post by: Munchor on December 01, 2010, 06:36:31 pm
Not yet, but I'm reading up.

Good luck then. I like Ti-OSs math stuff, so I'd ike them to be similar
Title: Re: Math
Post by: SirCmpwn on December 01, 2010, 06:41:13 pm
Thanks for the links, Qwerty.55
Title: Re: Math
Post by: AngelFish on December 01, 2010, 06:52:12 pm
You're welcome. One request though: Don't try to do that bloody mathprint thing. It's really annoying.
Title: Re: Math
Post by: SirCmpwn on December 01, 2010, 06:53:44 pm
I was going to have it as an option.  Don't worry, I would do it much better than TI.
Title: Re: Math
Post by: jnesselr on December 01, 2010, 07:59:47 pm
And much more stable.  I'm not sure how TIOS parses stuff. I know on higher languages, I try and make some sort of tree structure, and take what I have and go backward.  Will this be able to simplify polynomials? Is this completely part of the kernel, or is there like a "math app" type thing?
Title: Re: Math
Post by: calc84maniac on December 01, 2010, 09:29:42 pm
Hello,
Can we discuss methods of doing signed math in decimal, like TIOS does, in z80 assembly?
Here's how the TI-OS does it (you'll probably want something similar, but with a more optimized implementation of course).

Floating point values are stored in 9 bytes, using a scientific notation form. The first byte is the sign byte (Bit 7 is set if the value is negative, reset if positive. The rest of the byte is used for other miscellaneous info like the complex number identifier). The second byte is the exponent, which is the power of 10 in the scientific notation form (plus 128). Bytes 3-9 hold the significand of the number in binary-coded decimal. The decimal point goes between the first and second digit (the first digit can be 0 only if the entire value is 0).

Okay, now for a real-world example -- representation of the number -15.125:
(in hexadecimal) 80 81 15 12 50 00 00 00 00
which is -1.5125000000000 x 10^(129-128)

To add two floating point numbers, you must shift the significand of the smaller value to the right by one digit and increase its exponent until it has the same exponent as the larger value. Then you can add together both 7-byte numbers (using the DAA instruction after each addition to adjust the result to be correct for BCD math)