Offline
Milwaukee, WI

So I find myself with a large amount of free time over the next few months.  I've wanted to learn ASM for a while to program some of our favorite old machines, with the PC-Engine & Neo Geo specifically in mind.  Now, where to start?  I've got a background doing a bit of Java programming, but that's it.  I've seen a lot of excellent NES, SMS, and GB tutorials, so maybe start there and branch out?  Hit me up with links, places to hang out, info, etc.  I've got the time!

Thanks!

Last edited by Theta_Frost (Sep 12, 2013 11:41 pm)

Offline
Milwaukee, WI

Okay, I'm starting with this because it's amazing.  I'll have to switch some stuff around because I'm on Mac but it's still so well written!

http://www.smspower.org/maxim/HowToProgram/Index

Offline
Nomad's Land

The most important prerequisite for learning asm is having the dedication to master the very steep initial learning curve. You'll be doing a lot of reading before you can actually program something pratical. Once you've got a general "feel" for the language then things start to become really easy.

So if you're interested in PC Engine and Neo Geo, you'll have to learn 65SC02 and 68k assembly, respectively. I think 68k is somewhat easier for beginners, since it has a fairly straight-forward instruction set and loads of registers to play with.

Your starting kit should include an accurate emulator with debugging capabilities, a modern cross-assembler (preferably one that can link binaries into target-specific executables/roms/whatever), and a text editor that can show line numbers (and maybe even supports syntax highlighting for your asm flavor of choice). It's also a good idea to have opcode list for your target processor at hand, for quick reference.

A couple of tips I learned the hard way:

- Always comment your code. In the beginning, it's a good idea to comment every line. After a few days of not looking at it, even the most well-written asm code tends to present itself as an inprenetrable jungle.

- You'll have a lot of different files floating around, so organize your working directory well.

- Familiarize yourself with batch and/or shell script. Automatizing the build process with scripts will save you a lot of time on the long run.

I can't really point you to any good sites for programming PC-Engine and Neo Geo. I'm afraid a lot of good documentation might be in Japanese only. In any case tutorials for other systems won't be so helpful, especially not for SMS and GB. Might be good for a start, but otherwise you'll be wasting your time, because there are huge differences in programming the various 8-bitters.

Offline
Milwaukee, WI
irrlichtproject wrote:

Your starting kit should include an accurate emulator with debugging capabilities, a modern cross-assembler (preferably one that can link binaries into target-specific executables/roms/whatever), and a text editor that can show line numbers (and maybe even supports syntax highlighting for your asm flavor of choice). It's also a good idea to have opcode list for your target processor at hand, for quick reference.

Do you have any suggestion for a cross-assembler?  WLA DX seems to support most of the things I'm interested in, except the 68k.  vasm supports the 68k, but I haven't heard much about it.  Unfortunately, all the assemblers I can find are windows only which is a problem for the time being! hmm

Thank you so much!  Very helpful! smile

Offline
Nomad's Land

Sorry, can't help you with that, as I mainly program for Z80. It seems WLA DX is indeed the way to go for PC-Engine. There's also the HuC devkit, which includes an assembler. Btw starting out by using a C compiler such as HuC might be another feasible way of getting into asm programming.
For 68k why not try vasm. It may be somewhat less popular since users of the most common 68k systems (Amiga and Atari) don't do so much cross-assembling. If it doesn't work for you then you could also use gas from binutils.

Last edited by irrlichtproject (Sep 13, 2013 10:17 am)

Offline
Sweden

For any platform I'd:

  • Read up on the features of the platform. Read loads of memory maps, learn about the chips, the architecture.

  • Learn the operation codes of the CPU(/s). At least get a good idea of what kind of instructions are available.

  • Get into a comfortable assembly/build setup

  • Experiment with the platform features, memorizing code patterns as you do.

  • Figure out how to do things you'd typically do with a high-level language. Conditional execution, loops, array indexing, pointer passing, functions etc.

  • Learn the features of the assembler you're using.

  • Build a library of macros or just code snippets that you can use for otherwise repetitive tasks.

This is not so much a "crash course" as a long term plan for fully understanding the system and the whole development chain.

I don't think assemblers are a good way to learn the fundamental concepts of software design, so you should probably have a good idea about that before you take on a larger project. Spend a great deal of time considering what a compiler would do when you're writing. Break down problems into unproblematic parts.

A very good exercise since you are already programming in Java is to write an assembler. It's probably easier with something like the PC Engine CPU than the 68k, which has tons of addressing modes and registers.

Last edited by boomlinde (Sep 13, 2013 7:58 pm)

Offline
Nomad's Land

You are hereby awarded the irrlicht badge of honor for this excellent post, boomlinde.

One more important thing that came to my mind: Hang out in platform specific online communities, that's where you'll learn the most.

Offline

i can only speak for myself but imo Just Do It! dont read anything until you get stuck and then only read the things that will help you get unstuck

obveiously you still need a memory map and opcode list but you dont need to store them inside your head, they put themselves there after youve got stuck for the 100th  time

Offline
Murcia, Spain
irrlichtproject wrote:

- Always comment your code. In the beginning, it's a good idea to comment every line. After a few days of not looking at it, even the most well-written asm code tends to present itself as an inprenetrable jungle.

This should be tattooed in our hands.

Offline

- It's easier to learn on a home computer than a console.  Mainly because there's a lot less register setup and you can be a lot more generous with memory.  With a console you'll be dealing with either an off-the-shelf framework that won't be readable to you at the beginning, or coding that bit yourself. (which is a hassle you don't need when first starting out)   I'm glad I learnt on c64 first before moving to NES.

- As Sandneil said you don't need to learn a lot to start, you can do quite a few things with just 10-15 opcodes, if that.  Learning a full set isn't really useful until you get into optimisation.

- I've linked a couple of good tutorials but they're machine specific.   For 6502 I used TMR's The Hex Files which is based around the c64.   For 68000 Photon's recent Amiga video tutorials have explained the basics quite well though it is very amiga-centric.

- When looking at a new assembly language I'm basically looking for these things:
1) How do I get this value into that register?
2) How do I read that value back?
3) How do I compare one value against another?
4) How do I react to that to jump around my code?
5) How do I do some basic maths on there?  (add/dec/and/ora/shift etc)
6) How do I do loops?

After that you get into the machine-specific things like which registers control timing, put stuff on screen etc.  But those 6 things above are all you need to control the machine really.

Last edited by 4mat (Sep 15, 2013 2:30 pm)

Offline
Nomad's Land

Wow, didn't know about The Hex Files. Awesome resource, can't stop reading.