Great Way to Learn Assembly
I don't program in Assembly language on a regular basis, but every now and then, I get the opportunity to play with microcontrollers or other devices that require knowledge of assembly and/or machine code.
Being a high-level developer (VB, Java, C#), it's both interesting and extremely confusing to work at the machine's level. But, I found that a great way to teach myself a new assembly language is to actually write an emulator (simulator) in the high-level language to execute real/compiled machine code.
For instance, in the past, I wrote a simulator for the TMS370 microcontroller because I needed to learn its assembly language to write some serial I/O routines.
A better example for this audience might be to create an emulator for the Z80 microprocessor, simply because there's a lot of real-world programs that you can run (i.e., "Donkey Kong" arcade game used the Z80). Of course, emulating arcade machines involves more than just simulating the CPU and memory--you also need to emulate the graphics system in order to "see" if your CPU emulation is working correctly or not.
But, my point is simple--by forcing yourself to implement each opcode as part of an emulator, including all the different addressing variations, you will truly understand how the opcodes work. And, if you get stuck, you could always check the MAME source code (which emulates a multitude of popular CPUs).
Try it, if you dare! (btw--I'm toying with this very same idea for a book, if I can find the time....damn, I hate working so much).
|