|Any way to avoid getting stuck in code?
|Page 2 of 2|
|Author:||nicklausw [ Mon Apr 24, 2017 6:39 pm ]|
|Post subject:||Re: Any way to avoid getting stuck in code?|
That's either Billy from Power Rangers finding where the Zeo Crystals are, or Glen Beck finding the Illuminati headquarters.
Bit much hair for Billy iirc (even in Zeo).
My two pieces of advice for neat code mostly apply to assembly programs: don't be afraid to comment plentifully, and if you ever find yourself wanting to use multiple branches of anonymous labels (like --,+++,) don't. Just don't. Why? Because I have no idea what this routine that I wrote does.
+: ld c,a
++: ld a,2
++: dec hl
By that I don't mean that I can't figure out that the code calculates the range of something. I mean that what it's calculating the range of is unknown, and how it's doing so is even more unknown. What the anonymous labels point to is pretty much completely unknown. See the redundant wording? Yeah, everything is unknown.
Of course, that little snippet's outdated, and I have added tons of comments since, so sweet, problem solved. It probably took me an hour to add them, though, because by the time I got around to it, I really couldn't remember what the code was doing or how. Not a fun situation.
Oh, and something I didn't care about back when I wrote that: don't put whitespace before label names, at least not as much as you would for opcodes. It's ugly.
|Page 2 of 2||All times are UTC - 7 hours|
|Powered by phpBB® Forum Software © phpBB Group