| |
Smallest Endless Loop Without "GOTO" [2011] |
User rating: | awaiting 8 votes (8 left) |
Credits :
Download :
Look for downloads on external sites:
Pokefinder.org
User Comment Submitted by Jak T Rip on 11 September 2011
Wow, thanks for the explanation on GoTo / JMP! I was not aware of JMPs being an indication for badly structured code, but yes, it makes sense! | User Comment Submitted by TheRyk on 8 September 2011
"If you need to JMP around all crazy you have structured your code wrong in the first place and you'll have a nightmare finding bugs."
So true :) Being an ASM beginner I messed up NeoTunes so badly back then with JMP/JSR/RTS that I couldn't find the bug anymore and only patching by copying the stack helped. Bad style, of course ^^ | User Comment Submitted by Monte Carlos on 8 September 2011
@Perplex: RUN is lame because it clears all variables. ;) | User Comment Submitted by JackAsser on 8 September 2011
@DeeKay: Because in a structured environment you could jmp in and out of different nesting levels and stack levels causing all kinds of weird bugs.
Jumping out from a different nesting level is not so bad (i.e. c/c++ et al's break). Jumping out from a stack frame all of a sudden is not so bad either (i.e. return etc).
However jumping directly into a different nesting level, f.e. straight into a for-loop is bad. You will jump past the looping-variable initialization making it alot harder to debug and predict.
Jumping directly into another stack level (like JMPing into a subroutine that ends with an RTS) will make the stack pointer go crazy.
So, avoiding JMPs all together makes the code easier to predict and debug. As Oswald said, JMPs on the C64 is most often used to extend the range of the branches, or for endless loops, or for JMP-tables etc.
If you need to JMP around all crazy you have structured your code wrong in the first place and you'll have a nightmare finding bugs. | User Comment Submitted by DeeKay on 8 September 2011
funny. I had no idea you could write it "go to" instead of "goto", and I also thought that goto without anything would result in and undef'd statement error...
i played around with it a bit and it seems that for any NaN it does a GOTO 0, and *only* 0, it gives a shit about variables (as expected, always buggered me that you couldn't do GOTO A....)
BTW: Can anyone explain to me why just about every coding authority (Dijkstra etc) hates GOTO so much? 8) it's just the same as JMP in assembly, and I don't think any CPU exists that does not have this command... | User Comment Submitted by Skate on 8 September 2011 User Comment Submitted by TheRyk on 7 September 2011
Fun. I don't see it as a cheat. :) Wouldn't have been illegal in that competition (which was also fun but also a little strange, not using GOTO was the smallest issue, because too many other commands were allowed. It was rather about how to design a nice listing - whatever that means - and how to use the remaining 800 bytes to do sth beautiful on the screen or even with SID). A pity you didn't join in time, Monte! | User Comment Submitted by Jak T Rip on 7 September 2011 User Comment Submitted by Perplex on 7 September 2011
Actually "0 RUN" would be 2 bytes shorter (and less of a cheat.) |
|
|
|
| Search CSDb |
| Navigate | |
|
| Detailed Info | |
|
| Fun Stuff | |
· Goofs · Hidden Parts · Trivia
|
|
| Forum | |
|
| Support CSDb | |
|
| |
|