Author Topic: Axe Q&A  (Read 590537 times)

0 Members and 3 Guests are viewing this topic.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1245 on: December 17, 2011, 12:57:26 pm »
getKey(2)?X--
Evidently not, when I tried something like that it threw an error at compile-time. :/

I get no such error, and there should be no difference between the two syntaxes. You mentioned something about Pt-X commands not working in them, and this is true, but not because of a syntax difference. It's because Axe requires that some comamnds start a line, and the Pt-X commands are among them, so you can't use them mid-line in an inline conditional.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Q&A
« Reply #1246 on: December 17, 2011, 12:58:54 pm »
Any other often-used commands that can't be used with ? ?

Offline chattahippie

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +27/-0
  • Super Member! :D
    • View Profile
Re: Axe Q&A
« Reply #1247 on: December 17, 2011, 01:00:32 pm »
A ? is an "if and only if" statement, right?

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1248 on: December 17, 2011, 01:01:04 pm »
The general rule is, if the command token starts with a capital letter, it has to be at the start of a line.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Q&A
« Reply #1249 on: December 17, 2011, 01:03:49 pm »
Like the first word of a sentence :P

Ok, I guess there is a lot of differences since there's lots of commands starting with capitals.

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Axe Q&A
« Reply #1250 on: December 17, 2011, 01:04:50 pm »
So, the compiled size is the same?

(also 84 pages :P)

Also just noticed this:
i think that is becasue X-- is a command, not a value.  Try x-1->x
That one has worked for me, even in the conditional.

(btw @epic X-getKey(2)→X would work for the example code :P)
« Last Edit: December 17, 2011, 01:07:59 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1251 on: December 17, 2011, 01:08:11 pm »
Yes. X?Y produces the same code as If X : Y : End, and X?Y,Z produces the same code as If X : Y : Else : Z : End.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Axe Q&A
« Reply #1252 on: December 19, 2011, 07:07:12 am »
I have a question: why doesn't this code work? (It compiles, but it glitches on me)
0→{S}→{S+5}→{S+15}
and S is the pointer to appvar.
Sig wipe!

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 Q&A
« Reply #1253 on: December 19, 2011, 07:10:57 am »
I have a question: why doesn't this code work? (It compiles, but it glitches on me)
0→{S}→{S+5}→{S+15}
and S is the pointer to appvar.
(I just had this happen to me too and I spent a couple of hours before getting Runer's help and facepalming.)

Because of the way Axe optimizes, number→{pointer} returns the pointer instead of the number.  The code equivalent to what you are doing is actually this:
:0→{S} :S→{S+5} :S+5→{S+15}

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Axe Q&A
« Reply #1254 on: December 19, 2011, 07:13:30 am »
oh! D:
Thank you. Now I can optimize stuff a bit more!
(I was using 0→{S}:0→{S+5}:etc)
Sig wipe!

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1255 on: December 19, 2011, 11:37:24 am »
If you're wondering, the optimized way to do that would be:

and 0→{→{→{S}+5}+10}

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 Q&A
« Reply #1256 on: December 19, 2011, 06:03:44 pm »
If you're wondering, the optimized way to do that would be:

and 0→{→{→{S}+5}+10}
I find it both scary and hilarious how unreadable that is. I can almost guarantee that optimized Axe code will elict a WTF? from the viewer. Even if you're the one that wrote it :P
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 Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Axe Q&A
« Reply #1257 on: December 19, 2011, 08:39:44 pm »
question from the former code: what does that "and" do?
Sig wipe!

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #1258 on: December 19, 2011, 09:33:12 pm »
I think it generates the number 0 without actually storing it in the program.  It basically AND's the previous value of HL with 0, which always results in 0.  Similar to how assembly optimizers often do XOR A instead of Ld A,0

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 Q&A
« Reply #1259 on: December 19, 2011, 09:53:18 pm »
Since →{} stores only the lower eight bits (one byte), it doesn't matter what the high byte of HL is as long as the low byte is zero. In other words, all we need is for the last eight bits of HL to be zero. and 0 does a bitwise AND on the last eight bits of HL, which looks like this:
     ****************     // Original value of HL; * is either 0 or 1
and         00000000     //  and 0
     ********00000000     // Final value of HL
And that's all that's needed to store one byte of zero to {S}. It's also one byte smaller than just using 0 (LD L,0 versus LD HL,0), which is why Runer112 uses it.

Clever optimization there :D