Author Topic: Questions: DiagnosticOff and Goto  (Read 6400 times)

0 Members and 1 Guest are viewing this topic.

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Questions: DiagnosticOff and Goto
« on: November 24, 2010, 12:17:16 am »
In Axe, what precisely does DiagnosticOff and DiagnosticOn do?  The documentation states that it turns off the run indicator, plus prevents 'Done' from displaying, but the run indicator is never on normally (I think).  The User's Guide states that it leaves your code cleaner: in what way?

In Axe, are there any penalties for using Goto?  If I did this:

Code: (Example One) [Select]
For(X,0,9)
    Lbl EX1
End
Goto EX1
What would that do?

What about this?
Code: (Example Two) [Select]
Lbl EX2
Repeat...
    While...
        If...
            Goto EX2
        End
    End
End

And this?
Code: (Example 3) [Select]
Goto EX3
Repeat...
    While...
        If...
            Lbl EX3
        End
    End
End
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 yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Questions: DiagnosticOff and Goto
« Reply #1 on: November 24, 2010, 12:33:49 am »
The diadlgnostic off is really firllor changing in the middle of a program.  And the axe gotos have no memory leaks like basic, to just sucked.  :P

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Questions: DiagnosticOff and Goto
« Reply #2 on: November 24, 2010, 12:57:15 am »
In Axe, what precisely does DiagnosticOff and DiagnosticOn do?  The documentation states that it turns off the run indicator, plus prevents 'Done' from displaying, but the run indicator is never on normally (I think).  The User's Guide states that it leaves your code cleaner: in what way?

In Axe, are there any penalties for using Goto? 

<snip>

The run indicator is an OS interrupt. It's always on unless you shut it off.

As for Goto in Axe, it works slightly differently in Basic. In BASIC, the OS maintains a list of all of the conditionals and loops that it's working with. When you skip out of a conditional without going through the proper number of End commands, the calculator doesn't know to return the memory blocks holding those commands. In theory the OS should return all of the memory blocks back to the calculator after the program is finished executing. However, due to a programming error in the OS, it "loses track" of a few of them and those memory blocks are never returned. Run the program enough times and you'll find yourself very short on RAM. That's when Garbage collect should automatically kick in and return those blocks to the calculator.

In Axe, Gotos are completely different. What a Goto does is change what location in RAM the calculator looks for the next instruction at. The calculator doesn't record the end statements, so there's no potential for memory leaks. You can abuse the Goto command as much as you want without fear. Just remember to always return from subprograms because not doing so WILL cause memory leaks.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

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: Questions: DiagnosticOff and Goto
« Reply #3 on: November 24, 2010, 01:27:15 am »
The reason why the run indic might not be showing up is because you probably update that region of the screen so often that it makes it near impossible to see. I had this happen in Reuben Quest series.

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: Questions: DiagnosticOff and Goto
« Reply #4 on: November 24, 2010, 02:01:14 am »
In Axe, what precisely does DiagnosticOff and DiagnosticOn do?  The documentation states that it turns off the run indicator, plus prevents 'Done' from displaying, but the run indicator is never on normally (I think).  The User's Guide states that it leaves your code cleaner: in what way?
The run indicator crawls the ants every time you use an OS bcall in your program.  There are a lot of Axe commands that rely on these bcalls like for instance getkey (without parenthesis) or archiving/unarchiving.  Commands like these will indeed show the run indicator.

Code: (Example One) [Select]
For(X,0,9)
    Lbl EX1
End
Goto EX1
It would go to the next cycle of the for loop.  Whatever value X is at the moment will be the value it compares against to see if it should go to the next iteration.

Code: (Example Two) [Select]
Lbl EX2
Repeat...
    While...
        If...
            Goto EX2
        End
    End
End
It will restart the loop from the beginning, similar to what "continue" does in C.

Code: (Example 3) [Select]
Goto EX3
Repeat...
    While...
        If...
            Lbl EX3
        End
    End
End
It will jump to the middle of the loop.  But probably the conditional statements for the Repeat, While, and If will be using variables you need to make sure are all initialized correctly if you want to just jump in and expect things to work.

The only potential memory leak is if you try to jump out of a subroutine.  So be very careful if you attempt some weird optimization with that.
« Last Edit: November 24, 2010, 02:05:36 am 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: Questions: DiagnosticOff and Goto
« Reply #5 on: November 24, 2010, 02:04:44 am »
Wait, using getkey/archive/unarchive causes the run indicator to re-appear even if it was disabled?

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: Questions: DiagnosticOff and Goto
« Reply #6 on: November 24, 2010, 03:05:44 am »
Not if you disable it.  But its on by default.  You just sometimes don't notice it in some asm programs because it depends on the commands you use.
___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: Questions: DiagnosticOff and Goto
« Reply #7 on: November 24, 2010, 03:07:04 am »
Ah ok, thanks for the info. I think in CODEX, the archive/unarchive functions turned the indicator ON again if you disabled it. X.x

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Questions: DiagnosticOff and Goto
« Reply #8 on: November 24, 2010, 10:05:48 am »
Muhahaha!  Sweet.
No penalties, except in subroutines!
No more having to create elaborate 'While' or 'Repeat' loops to manage program flow!
Now the only thing I have to worry about is the occasional velociraptor.

*Michael wanders off whistling, planning.
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 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: Questions: DiagnosticOff and Goto
« Reply #9 on: November 24, 2010, 10:33:19 am »
Muhahaha!  Sweet.
No penalties, except in subroutines!
No more having to create elaborate 'While' or 'Repeat' loops to manage program flow!
Now the only thing I have to worry about is the occasional velociraptor.

*Michael wanders off whistling, planning.

Well, you can still jump around in subroutines, and even sub-sub-routines (however deep it is). Just remember to always return back for each one (instead of jumping back to the loop), and it should be fine.

And I love using Goto  in Axe programs. Occasionally I use it as the main loop of the program (Lbl LP:...:.code here:...:Goto LP:Lbl LE:End).
« Last Edit: November 24, 2010, 10:50:50 am by Deep Thought »




Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Questions: DiagnosticOff and Goto
« Reply #10 on: November 24, 2010, 10:35:07 am »
Now the only thing I have to worry about is the occasional velociraptor.
I dont get the cartoon... ???
I'm not a nerd but I pretend:

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Questions: DiagnosticOff and Goto
« Reply #11 on: November 24, 2010, 10:39:21 am »
The author is stating that the usage of 'goto' is so bad, that using it will cause a velociraptor to appear and kill you.
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 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: Questions: DiagnosticOff and Goto
« Reply #12 on: November 24, 2010, 10:39:27 am »
Now the only thing I have to worry about is the occasional velociraptor.
I dont get the cartoon... ???
I really like that one.  Tis' very funny. :P

Basically, using Goto is a bad thing.  The cartoon's saying that gotos are bad.  That's about all. :P

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: Questions: DiagnosticOff and Goto
« Reply #13 on: November 24, 2010, 10:50:33 am »
Now the only thing I have to worry about is the occasional velociraptor.
I dont get the cartoon... ???
I really like that one.  Tis' very funny. :P

Basically, using Goto is a bad thing.  The cartoon's saying that gotos are bad.  That's about all. :P

And so Axe is a pretty bad influence on comp coders ;D




Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Questions: DiagnosticOff and Goto
« Reply #14 on: November 24, 2010, 10:52:39 am »
Yah.  Which is probably why I'm having a wobber of a time trying to understand classes in Python.
But on the plus side, I understand pointers (probably)
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.