Omnimaga
Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Deep Toaster on October 13, 2010, 07:51:46 pm
-
Long time since I've touched TI-BASIC again (yes, Axe is that addicting ;D). I made a quick program that's becoming really useful for ASM: a program that calculates anything in binary, octal, decimal, hex, or any combination of the four. In other words, type in something like "b10110101+o571-x1E+241" and it'll output the answer as 769. Since it calculates using the expr( command, you can put literally any numerical expression in and it'll solve correctly, including exponents, trig, and other functions. Shot below :)
EDIT: New version uses all uppercase letters. Also, I changed hex to H. In other words, replace b with B, o with O, and x with H.
EDIT2: Even newer version changes it back -- sorry.
http://www.omnimaga.org/index.php?action=downloads;sa=view;down=591 (http://www.omnimaga.org/index.php?action=downloads;sa=view;down=591)
-
Nice!
-
Holy, that's awesome!
-
And so far, it's a nice, reasonable 295 bytes.
Anyone who finds any optimizations, feel free to post it!
-
does it take into account the base? like if i put in b0012, would it tell me that 2 won't work? or would it just calculate it as 4?
-
does it take into account the base? like if i put in b0012, would it tell me that 2 won't work? or would it just calculate it as 4?
It would actually calculate it as 22. Kinda weird, but let me explain:
All the program does is convert numbers of other bases to decimal for the OS to resolve. It uses a While loop for each number to detect when the number ends. In this case, the program knows that the number ends at that 2. So it inserts 2 into the final equation instead of b001, and it becomes 22.
I'm probably gonna change this. I've already decided what I'm going to do: I'm going to add parentheses around the number to be inserted, so that it becomes b0012=(b001)2=(2)2=4.
-
but what if the user mistypes b0011 into b0012? you mean your program will just convert this into 2*b001? then that begs the question, what if you have a string like b10201012? wouldn't your program mark it as 2*(b10) + 1012? i'd suggest getting the program to recognize that the given amount exceeds that of the maximum number possible, and then telling the user. regardless, it's a great program if you put in what you meant to (:
-
Hmm, good point. It would add ~50 bytes and make each pass a lot slower, though :(
Anyway, story behind the program:
It was horrible.
I'd made a program that I thought was brilliant (or at least very, very useful ;D). I wanted to share it on Omni, but (1) I lost my link cable; (2) WabbitEmu's Export feature was broken; and (3) SourceCoder still had bugs, which gave the program random syntax errors.
So I made the program with SourceCoder and started debugging it with Wabbit. Then I realized that even if I fixed it, I couldn't export it. So I opened up a hex editor (yes, on the comp, and yes, I'm suicidal, apparently). And so I began the task of individually editing hex codes to make it work.
That's when I got BSoD'd. It was horrible.
-
Nice utility!
-
Thanks, and I just realized something: It works almost the same way as Calcalca. Maybe I could combine them...
-
Mhmm idk. Calcalca is more math-oriented. Programmers might prefer to just have the base conversion to save as much space as possible. In my case I haven't needed math programs since the last time I had maths was 7 years ago ;D
-
Good point. Well, I'll change it a bit, add a readme, and hopefully release this tomorrow :)
-
Ok. Feel free to upload in the dl section :D
-
A question: Would people rather use lowercase letters for binary, octal, and hex at the cost of having an extra ASM sub, or just use uppercase?
-
Uppercase most deffinetaly, i can never keep my lowercase on, even with multiple apps that enable it on my calc.
-
Ya, I'd go uppercase. I mean it saves space and is just a lot less of a hassle :)
Great program though, I'll look through it tomorrow to see if I can find anything (though I'm sure nemo already has or will ;)). I'm assuming you use the prefix to determine what the base is then?
-
Uppercase. Often we will get RAM clears and forget to re-enable lowercase. Damn TI, why didn't they keep this enabled by default? It's even built in the TI-OS! x.x
-
Well I think what he was going to do is have a assembly built into the program that toggles it for the program when it's run so you can use them. Then turns them off when it's done. (I believe he did this with Calcalca (or how ever it's spelled, sorry to lazy to check right now :P))
Has the OS's ever had it enabled by default?
-
Nope, the OSes never had it enabled by default. I never understood why. It's there. Why did TI hide it?
-
Nope, the OSes never had it enabled by default. I never understood why. It's there. Why did TI hide it?
That's what I thought, but wasn't sure. Hmm, a possible TI-Cares email ;) :P
-
That's what I thought, but wasn't sure. Hmm, a possible TI-Is-Stupid-And-Doesn't-Care email ;) :P
Fixed.
-
Well if you want to get technical :P
-
I need to have all suggestions down before I edit the program, because each time I edit it I have to edit the hex directly on-comp. I already got BSoD'd :(
-
Darn I hope you can get rid of the bugs, good luck x.x
-
Nope, the OSes never had it enabled by default. I never understood why. It's there. Why did TI hide it?
That's what I thought, but wasn't sure. Hmm, a possible TI-Cares email ;) :P
My (silly) guess is that NoteFolio required it, so they added it to the OS... D:
-
Maybe, although I'm still wondering why they did not just enable it by default or have an option in MODE to enable it. X.x
-
I need to have all suggestions down before I edit the program, because each time I edit it I have to edit the hex directly on-comp. I already got BSoD'd :(
Why do you need to edit the hex directly?
-
SC didn't parse the Equ>String( token correctly.
Which reminds me: I need to post a bug report.
-
Yeah you should probably go report the bug to Kerm on Cemetech SC2 bug reports topic so he notices it faster.
-
Maybe, although I'm still wondering why they did not just enable it by default or have an option in MODE to enable it. X.x
Probably because that feature isn't needed at all for math. TI doesn't really care about our ability to write lowercase in our games D:
-
why is the symbol for hex a little x? why not h?
-
Strange I haven't paid attention. Could this be a typo?
EDIT: JosJuice, yeah but then I wonder why they put effort in even allowing to enable/disable it at all x.x
-
I chose x instead of h because it's used in a lot of comp languages (as in 0x2858EF29).
I can change it easily if you want, though.
-
I think we should go with h, because that's what is used more on-calc. Everytime I stumble on an ASM coder post he says stuff like 9000h or the like
-
I was actually thinking of also adding hexal (if anyone still uses that :P), which would be "h." Would anyone even use that, though?
Or I could add a [BASE]NUMBER syntax for any base.
-
Idk what does hexal means x.x
I think it should remain as numbers followed by h or h followed by numbers. Idk. Try to stick to the formats used in z80 assembly for the 83+
-
hexal is base 6. i'd suggest just having binary, octal, decimal and hexadecimal though.
-
Ah ok. yeah it might be best to just stick to these 4.
-
Yeah probably, and i second hex being prefaced by a h, although would it be very difficult to have x and h?
-
Yeah probably, and i second hex being prefaced by a h, although would it be very difficult to have x and h?
Not hard at all, but it'd make the prgm just a little bit slower. I'll change it to h, then.
And uppercase, right?
EDIT: Actually, here's the reason I chose lowercase: most people who code on their calcs will probably already have lowercase enabled, and it's not used in calc syntax anyway. In other words, there'd be no mixing up H*2*E and h2E. Maybe a poll?
-
yeah uppercase would be great :)
-
Posted a poll just for the fun of it. I'll probably change it to upper, though.
-
*bump* New version up in the first post (changed everything to uppercase and changed x to H). Enjoy!
I just edited it with SourceCoder, and I haven't tested it yet, so tell me if there are any syntax errors.
-
Cool, it should be easier to use :D
I really like how you can calculate multiple bases together.
-
I really like how you can calculate multiple bases together.
It basically just replaces the numbers in the string with the decimal equivalents :)
EDIT: By the way, how do I get rid of the poll?
-
At the bottom above the quick reply there should be a remove poll and lock topic option. I'll remove it for you if you don't see it, though.
-
Oh, thanks. Didn't see that ;D
-
UPDATE
Newest version now supports decimals (as in fractions). Don't know how that would be useful in coding, but oh well.
And I changed the B, O, and H back to lowercase -- sorry. I'll include an ASM sub to enable lowercase when I put this on ticalc.org, though.
-
What do you mean decimals as fractions? ???
Glad this is still progressing, though.
-
What do you mean decimals as fractions? ???
Glad this is still progressing, though.
Oh, I just meant stuff like x39E.29+b10110.1101*o367.20, etc. Before this digits after the decimal point were treated as base 10 no matter what.
Next up I'm going to add something actually useful: final conversion to hex, octal, and binary (most likely with ▶Rect, ▶Char, and ▶Polar).
-
I think I am even more confused now ;D but I think I might understand if I actually try it when it comes out. :P
-
Whoops, forgot to mention the update's actually up: http://ourl.ca/7416/128010 (link in first post).
-
Awesome but could you upload in ZIP format because it's against the rules to upload anything else than zip and mp3 files in the downloads section.
-
Forgot about that, sorry x.x
I'll fix it when I get home.