• Axe Parser 5 1
Currently:  

Author Topic: Axe Parser  (Read 554881 times)

0 Members and 2 Guests are viewing this topic.

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 Parser
« Reply #1755 on: May 09, 2011, 11:36:35 pm »
I'm planning a major feature addition soon which I am dubbing "Axsembly" (Please excuse my lack of creativity with portmanteaus :P).

Basically, it will allow direct assembly commands to be integrated directly into Axe... but while keeping the syntax looking almost exactly like regular Axe.  I will be using the lowercase letters for the registers and will allow a wide range of arithmetic instructions.  The major difference with Normal Axe syntax is that assignments are done with the equal sign instead of the store arrow (like in most programming languages) and only a limited range of instructions are allowed.  Both of these are to make Parsing on my side possible.  Everything else is basically the same as you're used to already.  There will also be a simple interface to transfer an Axe variable into a register for manipulation and then bring it back up.

For instance, the instruction "a=a+a" or "a=a*2" will both translate to the assembly instruction "add a,a".  However, "a=a*3" does not correspond to a single instruction, and therefore must be made by hand using 3 instructions like "b=a : a=a*2 : a=a+b".  There will also be some new operators like ++ which acts as an "inc" when used in a unary operation or an "add with carry" in a binary operation.  Different kinds of rotation will also be supported.  All these commands can be interwoven with current syntax, but I wouldn't rely on abusing the side effects because they can change from version to version.

This does have one conflict with Axe's current syntax however: The binary number prefix which is currently "b" will have to be changed to something else, but I think that command is used infrequently enough to not anger anyone who would be affected by this change.

I am hoping this will be a great introduction to assembly for new programmers who want to play around with it while staying in Axe's feature-rich environment.  This was a feature I was panning to add at the beginning, but then gave up, but just now thought of a way I could do it efficiently.
« Last Edit: May 09, 2011, 11:38:13 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Axe Parser
« Reply #1756 on: May 09, 2011, 11:42:11 pm »
So basically, is this equivalent to inserting hex into the program, except easier to read?
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Parser
« Reply #1757 on: May 09, 2011, 11:44:56 pm »
This sounds pretty awesome, although I am a little worried that this will make programming in Axe less "authentic," if you know what I mean. Although I do see the merits as well. But is it even necessary to change the b prefix for binary to something else? When parsing, if the b is followed by a 1 or 0, treat it as an indicator of binary data. Otherwise, treat it as the b register.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Axe Parser
« Reply #1758 on: May 09, 2011, 11:45:12 pm »
Wait--Axe now has side effects? O.o
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

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 Parser
« Reply #1759 on: May 09, 2011, 11:53:39 pm »
This sounds pretty awesome, although I am a little worried that this will make programming in Axe less "authentic," if you know what I mean. Although I do see the merits as well. But is it even necessary to change the b prefix for binary to something else? When parsing, if the b is followed by a 1 or 0, treat it as an indicator of binary data. Otherwise, treat it as the b register.
That's true, I guess I could do that.

Axe itself doesn't have side effects, but at the assembly level, the registers change around every time Axe does a native command.  Sometimes you can use these values for optimization.  Like if you knew the b register was always 0 after a Pt-On() for instance, you could use this knowledge to save some bytes.  However, I am simply warning against this because I could change the built-in routines at any time and an optimization like that might not work anymore.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Axe Parser
« Reply #1760 on: May 10, 2011, 11:53:30 am »
Will Axe create ASM programs even if the programs turn out to exceed 8 KBs? 

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Parser
« Reply #1761 on: May 10, 2011, 03:38:05 pm »
It will

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Parser
« Reply #1762 on: May 10, 2011, 04:37:21 pm »
Axsembly sounds pretty cool.  Good luck getting it to run smoothly. :)

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 Parser
« Reply #1763 on: May 11, 2011, 02:43:26 pm »
That sounds nice, but then for the contest somebody will have to help me judging entries, because I haven't coded Axe in almost one year and I'll need to scan every entry to make sure only a certain percentage of Asm() and your new ASM feature is used, and sadly I might not make the difference between Axsembly stuff and regular Axe code. ;D

Offline ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: Axe Parser
« Reply #1764 on: May 18, 2011, 08:13:54 pm »
Can somebody take a look at this code and see why everything up to "rand ^999→Q" repeats itself?
Code: [Select]
.KBYCRACK Crackity Hack!

prgmDEFINE
DiagnosticOff
sub(RCL)
sub(SSP,3,35,Pic1)
sub(SSP,25,30,Pic2)
sub(SSP,47,30,Pic3)
sub(SSP,69,35,Pic4)
sub(SSP,3,48,Pic5)
sub(SSP,25,43,Pic5)
sub(SSP,47,43,Pic8)
sub(SSP,69,48,Pic8)
sub(SET)
Repeat getKey(54)
DispGraph
End
sub(W)
0→T→P
Repeat T=4
40→X
1→A
Repeat getKey(54) or (X=40 and (A=2))
If A=1
Line(2,X/2+2,4,X/2+2)
ElseIf A=2
ref(2,X/2+2,3,1)
rref(2,X/2+2,3,1)
End
DispGraph
If X=0:2→A:End
If A=1:X-1→X:End
If A=2:X+1→X:End
End
If getKey(54)
sub(W)
40-X→X
X*X*X/371+P→P
Else
sub(W)
End
T+1→T
sub(SET)
End
20→X
Repeat getKey(54) or (X=100)
sub(RCL)
sub(FSP,5,30,Pic63)
sub(FSP,5,X/2,Pic6)
X+1→X
DispGraph
End
20-abs(60-X)→X
If X<0:0→X:End
X*X*31/40+P→P
sub(W)
conj(Pic01,L₃,768)
conj(Pic02,L₆,768)
sub(Q)
ClrDraw
sub(Q)
ClrDraw
sub(W)
rand ^999→Q
rand ^999→R
rand ^999→S
If P>999:999→P:End
P→Z
If Q>Z
Q→Z
ElseIf R>Z
R→Z
ElseIf S>Z
S→Z
End
0→X→Y
Fix 5
Repeat Z=X
If P≥X:sub(TSP,4,40,Pic7+Y):End
If Q≥X:sub(TSP,26,40,Pic7+Y):End
If R≥X:sub(TSP,48,40,Pic7+Y):End
If S≥X:sub(TSP,70,40,Pic7+Y):End
If Y=0
32→Y
Else
0→Y
End
Vertical -
Vertical -
Vertical -
ref(0,48,96,10)
rref(0,48,96,10)
If X≤P:Text(4,55,XDec):End
If X≤Q:Text(26,55,XDec):End
If X≤R:Text(48,55,XDec):End
If X≤S:Text(70,55,XDec):End
If X>P:Text(4,55,PDec):End
If X>Q:Text(26,55,QDec):End
If X>R:Text(48,55,RDec):End
If X>S:Text(70,55,SDec):End
If X<(Z-25)
X+10→X
ElseIf X<(Z-10)
X+1→X
Pause 100
Else
X+1→X
Pause 200
End
DispGraph
End
DispGraph
Return


Lbl Q
0→A
Repeat A=8
DispGraph
Horizontal +
Horizontal +
Horizontal +
Horizontal +
Vertical +
Vertical +
Vertical +
Vertical +
DispGraph
Horizontal -
Horizontal -
Horizontal -
Horizontal -
Vertical -
Vertical -
Vertical -
Vertical -
A+1→A
End
Return

Lbl SET
ref(1,1,5,22)
ref(1,1,5,22)
rref(2,2,3,20)
rref(2,2,3,20)
Return

Lbl W
0→A
Repeat A=40
DispGraph
A+1→A
End
Return

Lbl TSP
Plot1(r₁,r₂,r₃)
Plot1(r₁+8,r₂,r₃+16)
Return

Lbl FSP
Plot1(r₁,r₂,r₃)
Plot1(r₁+8,r₂,r₃+16)
Plot1(r₁,r₂+8,r₃+32)
Plot1(r₁+8,r₂+8,r₃+48)
Return

Lbl SSP
Plot1(r₁,r₂,r₃)
Plot1(r₁+8,r₂,r₃+16)
Plot1(r₁+16,r₂,r₃+32)
Plot1(r₁,r₂+8,r₃+48)
Plot1(r₁+8,r₂+8,r₃+64)
Plot1(r₁+16,r₂+8,r₃+80)
Return

Lbl RCL
conj(Pic0,L₃,768)
conj(Pic00,L₆,768)
Return
Anonymous Legend

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Axe Parser
« Reply #1765 on: May 18, 2011, 08:24:25 pm »
I don't know about your problem, but I do have an optimization:
Code: [Select]
If X≤P:Text(4,55,XDec):End
If X≤Q:Text(26,55,XDec):End
If X≤R:Text(48,55,XDec):End
If X≤S:Text(70,55,XDec):End
If X>P:Text(4,55,PDec):End
If X>Q:Text(26,55,QDec):End
If X>R:Text(48,55,RDec):End
If X>S:Text(70,55,SDec):End
becomes
Code: [Select]
Text(4,55,min(X,P)Dec)
Text(26,55,min(X,Q)Dec)
Text(48,55,min(X,R)Dec)
Text(70,55,min(X,S)Dec)
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: Axe Parser
« Reply #1766 on: May 18, 2011, 10:52:37 pm »
That sounds nice, but then for the contest somebody will have to help me judging entries, because I haven't coded Axe in almost one year and I'll need to scan every entry to make sure only a certain percentage of Asm() and your new ASM feature is used, and sadly I might not make the difference between Axsembly stuff and regular Axe code. ;D

So, if there are ASM commands, will they count as an Axe command?  Hehe >:D
« Last Edit: May 18, 2011, 10:52:56 pm by ralphdspam »
ld a, 0
ld a, a

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 Parser
« Reply #1767 on: May 19, 2011, 11:09:07 am »
2: ASM code must not compose more than 10% of your program code and the only allowed way to use assembly is via the Asm() command. The remaining 90% must be Axe or Axiom code. (See previous rule for Axiom information). Other languages such as TI-BASIC are NOT allowed.

Taken care of already :)




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 Parser
« Reply #1768 on: May 22, 2011, 11:27:05 pm »
Hmm... the problem with the new constants runs deeper than I thought.  The normal static pointers optimize with the assumption they will eventually be replaced by a value within the normal pointer range during the second pass since their actual value is unknown during the first pass.  Constants on the other hand ARE known on the first pass and this replacement model doesn't work in that case since the value is never updated during the next pass.  Therefore, this requires me to modify some very core routines.

So because I'll be rewriting this part anyway, I might finally add a request from a while ago which was to allow static variables to be used before they're defined.  So you can put data at the end of your program instead of only the beginning.  This has some drawbacks however:  First, it will be harder to debug errors.  Since the compiler won't know if a symbol is defined until the end of the source, it would not be able to scroll to the specific place it was used and would instead have to just display "Missing: Str1A" for example, just like labels.  Secondly, it uses up an extra symbol in the symbol table for each use until its finally defined.  As an example of this, here is the symbol count for this program:

Code: [Select]
:.TEST
:Str1       ;1 Symbol
:Str1       ;2 Symbols
:Str1       ;3 Symbols
:"H"->Str1  ;Now defined, so 1 symbol from now on
:Str1       ;1 Symbol
:Str1       ;1 Symbol
:Str1       ;1 Symbol

I'm guessing this will result in a lot of "MAX SYMBOLS" errors if people start using this too much since you only get 153 symbols to use.  What are everyone's thoughts about this?  Is it worth the extra effort?  I feel like most people who would use this would want to use it on large programs in which case they would probably run out of symbols anyway and be forced to move them back on top, which is a very annoying process.
« Last Edit: May 22, 2011, 11:28:59 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Parser
« Reply #1769 on: May 22, 2011, 11:29:08 pm »
I personally vote for another pass. That would solve the problem, wouldn't it? For me, even massive programs still compile in only a few seconds. I think giving up an additional second or two would be acceptable to allow for more free program structure.
« Last Edit: May 22, 2011, 11:35:29 pm by Runer112 »