Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: calc84maniac on September 08, 2010, 11:27:43 am

Title: Axe 8-bit math ideas
Post by: calc84maniac on September 08, 2010, 11:27:43 am
I figured it's about time to make a topic about the eventual 8-bit math mode that will be included in Axe. Post any suggestions, ideas, etc.

Here are mine. About the syntax, I was considering the possibility of enclosing 8-bit expressions with single quotes. But then I found out those are currently in used as 'CHAR' constants. So my other idea is using inverted brackets, like so:
]8-bit stuff goes here[

For example, you could have
]A+5->A[

which would compile to
Code: [Select]
ld a,(var_A)
add a,5
ld (var_A),a

The compiler should keep track of whether the "last answer" is 8-bit or 16-bit, and do a conversion if operating with a different bit length.

For example:
]A+5[->B

would compile to
Code: [Select]
ld a,(var_A)
add a,5
ld l,a
ld h,0
ld (var_B),hl

Perhaps it could also be possible to force signed conversion, like so (the value will be interpreted as -128 to 127):
]A+5[r->B

which would compile to the following:
Code: [Select]
ld a,(var_A)
add a,5
ld l,a
rla
sbc a,a
ld h,a
ld (var_B),hl

Using memory read brackets {} in 8-bit mode should force 16-bit mode within the brackets.
Example:
]A+{P+1->P}->A[

Compiled code:
Code: [Select]
ld a,(var_A)
push af ;save A in case it will get overwritten (seems to be an Axe standard)
ld hl,(var_P)
inc hl
ld (var_P),hl
pop af
add a,(hl)
ld (var_A),a

That's all for now! Direct comments, questions, concerns to your local Netham45.
Title: Re: Axe 8-bit math ideas
Post by: matthias1992 on September 08, 2010, 12:12:13 pm
maybe this is really silly because I am a total axe newb but, unless Quibi...(ehr I always forget his name..sorry) plans to implent this anywhere soon why don't you make a axiom out of it? (< not to be rude, just a suggestion) I think it might be quite helpful especially for those who really want to sqeeuze bytes out of their programs...
Title: Re: Axe 8-bit math ideas
Post by: calc84maniac on September 08, 2010, 12:17:27 pm
I don't think Axioms allow for things like this. This is something that would need to be supported in Axe itself (and Quigibo has said that he plans to add 8-bit math at some point. I'm just getting the ball rolling :) )
Title: Re: Axe 8-bit math ideas
Post by: meishe91 on September 08, 2010, 02:21:32 pm
I really wish I knew what this is about exactly, like understood it all. What advantage does 8-bit have over 16-bit?
Title: Re: Axe 8-bit math ideas
Post by: DJ Omnimaga on September 08, 2010, 02:29:07 pm
I think it might be a bit faster, although for small stuff it might not be very noticeable
Title: Re: Axe 8-bit math ideas
Post by: Builderboy on September 08, 2010, 02:39:51 pm
I believe its also much smaller, so there is a size advantage as well as a speed advantage
Title: Re: Axe 8-bit math ideas
Post by: Quigibo on September 08, 2010, 04:47:57 pm
Hmm, interesting to use 'inverted' brackets. That has got to go against all the language theories but that actually would work which is the interesting part :P

The problem with that though is that I think it would be beneficial to keep the 8-bit mode from line to line so you don't need to keep using the brackets.

Code: [Select]
]A+1->A[
]B+1->B[

<8bit>
A+1->A
B+1->B
<16bit>

Where <8bit> and <16bit> are some undecided token that indicates a switching of the modes.  They can be used inline as well.

This is something that you won't see soon though, probably not until 2.0 (Axe++) because it basically requires me to rewrite an entirely new copy of the math library including new optimizations, conversions, and other technical issues I would have to deal with.  I was also thinking of allowing the use of some lowercase letters to correspond to their registers for the lowest possible level of optimization.
Title: Re: Axe 8-bit math ideas
Post by: DJ Omnimaga on September 08, 2010, 05:14:11 pm
Yeah at first I found this weird too. ;D . Do you think it could cause problems during parsing? I wonder if there could be another character that could be used if it's the case? (maybe a new token?)
Title: Re: Axe 8-bit math ideas
Post by: LordConiupiter on September 08, 2010, 05:21:40 pm
register access! that would be really cool!
for the 8bit and 16bit tokens: perhaps RADIAN -> 8bit and DEGREE -> 16bit? or wouldn't the words in the mode menu change when the token names are changed?
Title: Re: Axe 8-bit math ideas
Post by: calcdude84se on September 08, 2010, 06:04:23 pm
Direct register access would be interesting... But at that point, it's pretty much straight ASM... Maybe you could have a small inline assembler? No need for label support or anything. That would still be a lot of work, though.
8-bit math would definitely be useful; I'm already thinking of some optimizations I can make to my programs ;D
Title: Re: Axe 8-bit math ideas
Post by: DJ Omnimaga on September 08, 2010, 06:23:32 pm
Yeah register access would be nice. It would extend the language so it can do more stuff that only ASM can do normally, while still having some higher level functions similar to TI-BASIC. This is what makes Axe so great IMHO. We can do some basic-like stuff that runs at ASM speed, but we can store stuff where we want in RAM, like ASM
Title: Re: Axe 8-bit math ideas
Post by: Builderboy on September 08, 2010, 06:28:33 pm
Hmmm how would register access work well though?  Since there are so many restrictions on what you can add and what you can store to.  Like you cant add register b and c with one command.  I guess it would be an especially asmers only command?
Title: Re: Axe 8-bit math ideas
Post by: Deep Toaster on September 08, 2010, 07:27:29 pm
Yep, register access would be great. How about X1T for A, Y1T for F, and so on, so that we have obvious register pairs?
Title: Re: Axe 8-bit math ideas
Post by: calcdude84se on September 08, 2010, 07:44:46 pm
We would then need commands to access them (overloading?), and ways to deal with register pairs as a whole (like a way to do "ld (de),a", for example), and also more instructions (like in a,(N) or in b,(c) or even rlc ixh :P)
I'd personally like an inline assembler (w/o labels, as above) but this could work too ;D
Title: Re: Axe 8-bit math ideas
Post by: Deep Toaster on September 08, 2010, 07:48:30 pm
Or we could always use Asm( ;)
Title: Re: Axe 8-bit math ideas
Post by: Builderboy on September 08, 2010, 07:50:03 pm
I like the way you think Deep Thought ;) IMHO if we are going to be doing such complicated things that we are coding in half asm and half axe at the same time, maybe it would just be easier to code in straight asm or add in some small hex codes for small things
Title: Re: Axe 8-bit math ideas
Post by: DJ Omnimaga on September 08, 2010, 07:50:41 pm
Although then it cannot be used in future contests :P (unless they're not pure-Axe-only)
Title: Re: Axe 8-bit math ideas
Post by: calcdude84se on September 08, 2010, 07:53:20 pm
The problem with Asm( is that it's difficult to read hex, while reading ASM is much simpler in comparison. Just my opinion ;)
Maybe I should just wait for Mosaic at this point, though mixing Axe and ASM would be nice.
Title: Re: Axe 8-bit math ideas
Post by: Deep Toaster on September 08, 2010, 07:57:54 pm
Right now, I'm using OTBP to assemble short ASM clips into hex, then using that for Asm(. It actually works pretty well.
Title: Re: Axe 8-bit math ideas
Post by: Quigibo on September 08, 2010, 09:42:54 pm
If native registers were supported, it would only be the most basic use of the registers: loading, adding, subtracting, and shifting, plus maybe a few simple things I'm not thinking about.  It would only allow things that are legal in asm so you wouldn't be able to add b and c and store the result in d.  Don't forget that part of implementing the 8 bit mode is moving the variables close enough to relative reference with IY so there are more optimizations possible.

By the way, I'm taking an assembly class using MIPS architecture (very similar to ARM) which feels like such a higher level language compared to z80.  Those instructions are specifically designed to translate from C compilers and only now do I realize why there haven't been many good assemblers for z80 so far :P.
Title: Re: Axe 8-bit math ideas
Post by: DJ Omnimaga on September 08, 2010, 10:11:34 pm
Nice Quigibo! And Yeah, the calc using a 8 bit processor doesn't help much x.x. I heard it was much easier to code in ARM assembly than z80, for example.
Title: Re: Axe 8-bit math ideas
Post by: Builderboy on September 09, 2010, 01:13:23 am
THose optimizations and features sound great :D Im especially excited for 8 bit mode ^^
Title: Re: Axe 8-bit math ideas
Post by: Deep Toaster on September 09, 2010, 07:07:58 pm
Hey, I have another idea for register access. How about using Greek letters, like α for register A, β for B, γ for C, δ for D, ε for E, and σ for F (since it kinda looks like a "flag" anyway ;))? If someone's so good with calculators that he wants to use the native registers, he can probably access the restricted tokens pretty well.
Title: Re: Axe 8-bit math ideas
Post by: DJ Omnimaga on September 09, 2010, 07:47:10 pm
Those are pretty hard to access, though. It would be best to choose tokens that are available without having to use a 3rd party program, even if it means renaming ANOVA( to A (slightly modified to stand out from the regular A) or the like
Title: Re: Axe 8-bit math ideas
Post by: Deep Toaster on September 09, 2010, 08:04:51 pm
Maybe he could use the X[NUM]T tokens, but replacing them with the greek letters. In that case, flags could be replaced with that weird serif'd F.