Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Deep Toaster on October 13, 2010, 07:51:46 pm

Title: FOR ASM/AXE CODERS: BaseCalc
Post 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)
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: SirCmpwn on October 13, 2010, 07:52:14 pm
Nice!
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Hot_Dog on October 13, 2010, 07:52:42 pm
Holy, that's awesome!
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 13, 2010, 07:54:10 pm
And so far, it's a nice, reasonable 295 bytes.

Anyone who finds any optimizations, feel free to post it!
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: nemo on October 13, 2010, 07:55:05 pm
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?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 13, 2010, 08:10:44 pm
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.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: nemo on October 13, 2010, 08:18:00 pm
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 (:
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 13, 2010, 08:19:36 pm
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.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 13, 2010, 11:43:35 pm
Nice utility!
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 13, 2010, 11:46:30 pm
Thanks, and I just realized something: It works almost the same way as Calcalca. Maybe I could combine them...
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 13, 2010, 11:55:38 pm
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
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 13, 2010, 11:59:35 pm
Good point. Well, I'll change it a bit, add a readme, and hopefully release this tomorrow :)
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 14, 2010, 12:01:21 am
Ok. Feel free to upload in the dl section :D
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 14, 2010, 12:03:15 am
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?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Builderboy on October 14, 2010, 12:56:00 am
Uppercase most deffinetaly, i can never keep my lowercase on, even with multiple apps that enable it on my calc.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: meishe91 on October 14, 2010, 02:37:49 am
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?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 14, 2010, 03:30:45 am
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
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: meishe91 on October 14, 2010, 03:43:56 am
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?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 14, 2010, 03:45:15 am
Nope, the OSes never had it enabled by default. I never understood why. It's there. Why did TI hide it?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: meishe91 on October 14, 2010, 03:46:17 am
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
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 14, 2010, 03:52:25 am
That's what I thought, but wasn't sure. Hmm, a possible TI-Is-Stupid-And-Doesn't-Care email ;) :P
Fixed.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: meishe91 on October 14, 2010, 03:57:13 am
Well if you want to get technical :P
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 14, 2010, 09:28:15 am
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 :(
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 14, 2010, 09:47:19 am
Darn I hope you can get rid of the bugs, good luck x.x
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: JosJuice on October 14, 2010, 12:28:13 pm
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:
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 14, 2010, 05:26:57 pm
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
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: meishe91 on October 14, 2010, 06:05:58 pm
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?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 14, 2010, 07:12:14 pm
SC didn't parse the Equ>String( token correctly.

Which reminds me: I need to post a bug report.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 14, 2010, 11:52:09 pm
Yeah you should probably go report the bug to Kerm on Cemetech SC2 bug reports topic so he notices it faster.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: JosJuice on October 15, 2010, 10:47:45 am
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:
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Eeems on October 15, 2010, 10:51:28 am
why is the symbol for hex a little x? why not h?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 15, 2010, 11:32:31 am
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
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 15, 2010, 04:50:13 pm
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.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 15, 2010, 05:50:47 pm
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
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 15, 2010, 06:02:27 pm
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.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 15, 2010, 07:49:43 pm
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+
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: nemo on October 15, 2010, 07:51:32 pm
hexal is base 6. i'd suggest just having binary, octal, decimal and hexadecimal though.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 15, 2010, 07:56:42 pm
Ah ok. yeah it might be best to just stick to these 4.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Builderboy on October 16, 2010, 01:52:13 pm
Yeah probably, and i second hex being prefaced by a h, although would it be very difficult to have x and h?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 16, 2010, 03:07:23 pm
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?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Builderboy on October 16, 2010, 03:09:51 pm
yeah uppercase would be great :)
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 16, 2010, 05:18:47 pm
Posted a poll just for the fun of it. I'll probably change it to upper, though.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 25, 2010, 05:06:27 pm
*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.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 25, 2010, 05:08:48 pm
Cool, it should be easier to use :D

I really like how you can calculate multiple bases together.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 25, 2010, 05:10:02 pm
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?
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on October 25, 2010, 06:34:22 pm
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.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on October 25, 2010, 07:44:03 pm
Oh, thanks. Didn't see that ;D
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on December 05, 2010, 01:14:30 am
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.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on December 05, 2010, 02:22:01 am
What do you mean decimals as fractions? ???

Glad this is still progressing, though.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on December 05, 2010, 10:46:50 am
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).
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on December 05, 2010, 05:31:21 pm
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

Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on December 05, 2010, 11:21:50 pm
Whoops, forgot to mention the update's actually up: http://ourl.ca/7416/128010 (link in first post).
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: DJ Omnimaga on December 06, 2010, 02:02:21 am
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.
Title: Re: FOR ASM/AXE CODERS: BaseCalc
Post by: Deep Toaster on December 06, 2010, 02:12:25 pm
Forgot about that, sorry x.x

I'll fix it when I get home.