• Axe Parser 5 1
Currently:  

Author Topic: Axe Parser  (Read 565430 times)

0 Members and 3 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 #1305 on: October 02, 2010, 03:48:41 pm »
If you want a really extreme optimization for or-ing the screen, here it is.  It will be noticeably faster and smaller:

Code: [Select]
.# represents the 16-bit or operation
L₆→A
While -768-L₆
{A}ʳ#{A+L₃-L₆}ʳ→{A}ʳ+1→A
End
« Last Edit: October 02, 2010, 03:56:18 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

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 #1306 on: October 02, 2010, 04:18:53 pm »
Infinite loop much? D:

Edit:
Oh, that is the minus sign, not the negative sign.
« Last Edit: October 02, 2010, 04:19:38 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

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 #1307 on: October 02, 2010, 08:15:29 pm »
That's pretty much the way to do it. You'd be surprised just how fast one massive For() loop that OR's the contents of both buffers is, though. I calculated that the following loop runs about 40 times per second at 6MHz:

Code: [Select]
Repeat getKey(15)
For(A,0,383)
.That ﹢ symbol is the 16-bit OR operator
{A*2+L₆}ʳ﹢{A*2+L₃}ʳ→{A*2+L₆}ʳ
End
C+1→C
End

Whoa, how'd you get the small r to work in a code tag?




Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Axe Parser
« Reply #1308 on: October 02, 2010, 08:59:32 pm »
WONDERFUL
that will do nicely, thanks
EDIT:oh, and ʳ is a character of its own
« Last Edit: October 02, 2010, 09:03:13 pm by shmibs »

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Axe Parser
« Reply #1309 on: October 02, 2010, 09:02:25 pm »
That's pretty much the way to do it. You'd be surprised just how fast one massive For() loop that OR's the contents of both buffers is, though. I calculated that the following loop runs about 40 times per second at 6MHz:

Code: [Select]
Repeat getKey(15)
For(A,0,383)
.That ﹢ symbol is the 16-bit OR operator
{A*2+L₆}ʳ﹢{A*2+L₃}ʳ→{A*2+L₆}ʳ
End
C+1→C
End

Whoa, how'd you get the small r to work in a code tag?
"ʳ"  There is a symbol for it. Just copy/paste.

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 #1310 on: October 02, 2010, 10:49:19 pm »
Nice. Thanks!




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 #1311 on: October 03, 2010, 04:40:04 am »
woah, that's one extreme optimization and routine :O

I will have to study the code hard to understand it but I'm glad to see it is possible to do that. Thanks a lot

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Axe Parser
« Reply #1312 on: October 03, 2010, 05:22:45 pm »
Quick question: Is this:
Code: (1 byte variable For() loop) [Select]
min→{L1+A}
While {L1+A}<max
{L1+A}+1→{L1+A}
<code>
End

faster than:

Code: (Standard For() loop) [Select]
For(Var, min, max)
<code>
End

?

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Axe Parser
« Reply #1313 on: October 03, 2010, 05:23:30 pm »
I would hope a for loop is faster, though Quigibo will have to back me up on this.
"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 Parser
« Reply #1314 on: October 03, 2010, 05:32:04 pm »
Quick question: Is this:
Code: (1 byte variable For() loop) [Select]
min→{L1+A}
While {L1+A}<max
{L1+A}+1→{L1+A}
<code>
End

faster than:

Code: (Standard For() loop) [Select]
For(Var, min, max)
<code>
End

?


The For( loop is definitely faster if the first one uses one-byte numbers, because in Axe all operations are 16-bit. So in the one with the While loop, the program has to convert the numbers back and forth between 8- and 16-bit, and that takes a bit longer. Plus it's bigger. So use the For( loop :)




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 #1315 on: October 03, 2010, 06:32:43 pm »
A while loop is better if you can avoid a comparison operation and use the "0 is false everything else is true" instead:

Code: [Select]
For(A,0,5)
<code>
End

0->A
While -5
<Code>
A+1->A
End

The second one is actually smaller and faster than the first one.  The only reason I can't make this the default behavior for the for loop is actually because if A happens to be above 5 in this example, it would keep counting up until it passes 65536 and loops back to 5 again.  You're basically coding a less optimized for loop here but since you skip the comparison, it actually makes it 1 byte smaller and negligibly faster.
« Last Edit: October 03, 2010, 06:34:45 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

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 #1316 on: October 03, 2010, 07:47:31 pm »
On a related question,
Code: (Axe) [Select]
:Lbl LP
//code
:Goto LP
would be more efficient than
Code: (Axe) [Select]
:While 1
//code
:End
right? If so, a quick feature request: automatically making While 1 and Repeat 0 infinite loops.




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 #1317 on: October 03, 2010, 07:48:14 pm »
And using a While loop, you can use steps other than 1 :)


Edit:
I got somewhat ninja'd, so I was still talking about For( loops.
« Last Edit: October 03, 2010, 07:49:00 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

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 #1318 on: October 03, 2010, 07:52:25 pm »
True. And just wondering: Does anyone have an example of where DS<( would be useful?




Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Parser
« Reply #1319 on: October 03, 2010, 08:59:33 pm »
True. And just wondering: Does anyone have an example of where DS<( would be useful?

DS<() Is useful when you have something in a loop/interrupt that you don't want to run every iteration. For instance, if you want to update the screen in a program's main loop or in an interrupt but don't want the screen updating too often (to save processing power for other things), enclose the screen updating portion in something like DS<(A,4) so the screen is only updated every fourth iteration.
« Last Edit: October 03, 2010, 09:01:27 pm by Runer112 »