The perfect "Hello World" example for new starters
Posted: Sun Apr 02, 2017 12:56 pm
I keep getting asked to re-upload my Hello World sample from my blog, but it was a learning experience riddled with bad practices so letting it circulate further wouldn't do anyone any good.
5 years on I'm now experienced and would like to rewrite every article into proper tutorials, but as a stop-gap measure I'd like to throw the idea of coming up with the perfect Hello World sample we can point newcomers at to get them started quickly. Existing examples are hard to find, aren't very beginner friendly, are poorly documented, or target specific toolchains.
I ran a workshop on Mega Drive coding at the NVA last year, which ended up with this: https://pastebin.com/kJC99PA7 (and the workshop slides to go with it: https://docs.google.com/presentation/d/ ... sp=sharing).
It might be a good base to start, I'll do some cleanup and add extra comments, but does anyone have any thoughts?
Since it's aimed at beginners, I propose the following:
- Target Motorola syntax
- Compatible with most major assemblers (asm68k, snasm68k, asmx, vasm) with example command lines for each
- Comments for every line (i.e., remind the reader what a particular register is currently being used for every time it's written to)
- Prefer verbose methods that teach, over high performance code that obfuscates (within reason, see next point)
- Shouldn't show or encourage "newbie mistakes" or bad practices
- Should be reusable and extendable
- Define/equate all "magic numbers" or addresses
- Must work on all revisions of real hardware (my original didn't)
Most importantly, it needs to be an example we all agree on as being clean, and won't teach any bad practices.
5 years on I'm now experienced and would like to rewrite every article into proper tutorials, but as a stop-gap measure I'd like to throw the idea of coming up with the perfect Hello World sample we can point newcomers at to get them started quickly. Existing examples are hard to find, aren't very beginner friendly, are poorly documented, or target specific toolchains.
I ran a workshop on Mega Drive coding at the NVA last year, which ended up with this: https://pastebin.com/kJC99PA7 (and the workshop slides to go with it: https://docs.google.com/presentation/d/ ... sp=sharing).
It might be a good base to start, I'll do some cleanup and add extra comments, but does anyone have any thoughts?
Since it's aimed at beginners, I propose the following:
- Target Motorola syntax
- Compatible with most major assemblers (asm68k, snasm68k, asmx, vasm) with example command lines for each
- Comments for every line (i.e., remind the reader what a particular register is currently being used for every time it's written to)
- Prefer verbose methods that teach, over high performance code that obfuscates (within reason, see next point)
- Shouldn't show or encourage "newbie mistakes" or bad practices
- Should be reusable and extendable
- Define/equate all "magic numbers" or addresses
- Must work on all revisions of real hardware (my original didn't)
Most importantly, it needs to be an example we all agree on as being clean, and won't teach any bad practices.