Author Topic: More Precision on the 83+/84+ (10^127 - 10^-127)  (Read 7307 times)

0 Members and 1 Guest are viewing this topic.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3913
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: More Precision on the 83+/84+ (10^127 - 10^-127)
« Reply #15 on: November 09, 2012, 03:39:10 pm »
Hehe :D viva les z80 guys :D They are the guys that understand how we feel.
I'm not a nerd but I pretend:

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: More Precision on the 83+/84+ (10^127 - 10^-127)
« Reply #16 on: November 09, 2012, 04:44:06 pm »
I'd noticed that the restriction was arbitrary, but I never considered hacking the OS to remove it. Your understanding of the EOS amazes me.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1591
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: More Precision on the 83+/84+ (10^127 - 10^-127)
« Reply #17 on: November 09, 2012, 08:52:45 pm »
I'd noticed that the restriction was arbitrary, but I never considered hacking the OS to remove it. Your understanding of the EOS amazes me.

It wasn't really all that difficult to do since like you said, I knew it was arbitrary.

The first step was to prevent ERR:OVERFLOW. For this, I did 1E99 + 9E99 and set a break point at _FPAdd. From there, I just stepped through the code and waited for an ERR:OVERFLOW to be thrown. After about 3 iterations of this, I finally stumbled upon _CkValidNum which clearly compared the exponent to +99 and -99. I just disabled that check :P (Actually, I still check for E-128)

The second step was to allow 3 digit exponents, but again, this was just a bit of "find the error." I set a breakpoint in the massive parser loop (endless "CP \ jr z" table) and watched as the errors unfolded for E127. I soon found a routine that used RLD to rotate the low nibble of the current byte being parsed into memory and I saw that on the third iteration, the memory location became invalid and a counter went to zero. My solution for this was just to do some code injection where I put a call to the end of the page and wrote my own routine to parse the number. All I had to do was watch for the overflow and add $A0 (BCD hack) if the new exponent was going to be in the correct 100-127 range and increase the counter by 1 to avoid the error.


So I guess that's a bit complicated, but the idea is that if something throws an exception, it's not very hard to catch by stepping through the code.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: More Precision on the 83+/84+ (10^127 - 10^-127)
« Reply #18 on: November 09, 2012, 10:17:21 pm »
Nice work penguin.

I don't have much else to say. Although the explanation of how you tracked it down is pretty cool and useful as well. Good job.

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: More Precision on the 83+/84+ (10^127 - 10^-127)
« Reply #19 on: November 09, 2012, 11:47:18 pm »
Wow!  This is amazing!

It always annoys me when they place arbitrary restrictions in their OS.
ld a, 0
ld a, a

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: More Precision on the 83+/84+ (10^127 - 10^-127)
« Reply #20 on: November 12, 2012, 12:49:36 am »
Some routines seem to like to check that their argument is in the old bounds. For example, sqrt(E100) works, but trying E100^.5 fails with ERR:OVERFLOW.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3004
  • Rating: +445/-10
    • View Profile
Re: More Precision on the 83+/84+ (10^127 - 10^-127)
« Reply #21 on: November 12, 2012, 06:46:34 am »
ThePenguin77, you never cease to amaze me :)