Author Topic: Axe 8-bit math ideas  (Read 12808 times)

0 Members and 1 Guest are viewing this topic.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Axe 8-bit math ideas
« 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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Axe 8-bit math ideas
« Reply #1 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...
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Axe 8-bit math ideas
« Reply #2 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 :) )
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Axe 8-bit math ideas
« Reply #3 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?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Axe 8-bit math ideas
« Reply #4 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

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe 8-bit math ideas
« Reply #5 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

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Axe 8-bit math ideas
« Reply #6 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.
« Last Edit: September 08, 2010, 04:49:40 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Axe 8-bit math ideas
« Reply #7 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?)

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Axe 8-bit math ideas
« Reply #8 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?
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Axe 8-bit math ideas
« Reply #9 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
« Last Edit: September 08, 2010, 06:04:35 pm by calcdude84se »
"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 DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Axe 8-bit math ideas
« Reply #10 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

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe 8-bit math ideas
« Reply #11 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?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe 8-bit math ideas
« Reply #12 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?




Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Axe 8-bit math ideas
« Reply #13 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
"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 Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe 8-bit math ideas
« Reply #14 on: September 08, 2010, 07:48:30 pm »
Or we could always use Asm( ;)