What's the best system on which to learn ASM?

Started by
22 comments, last by CalvinCoder 8 years, 6 months ago

I'd target the machine you actually want to target :)

Obviously I'm biased for the C64, there's documentation abundant and there's no problem getting decent cross compilation tools.

<SelfAd>I recommend C64-Studio, my Visual Studio like IDE, which uses (Win)VICE for a neat debugging experience.</SelfAd>

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Advertisement

It really depends on what you value.

For accessibility, x86/x64 is simple because you can do it right on your PC. This means fewer headaches -- debugging your assembly code is a lot easier when its running on your host, and its also easier to write the high-level parts of your program in, say, C or C++, without the slight pain of dealing with cross-compilers, deployment to a device, etc. ARM, in the form of a raspberry Pi is also a good choice for the same reasons (With the Pi being a complete, if modest, linux-based PC).

What you don't on either of those platforms is unfettered access to the machine. If you're interested in that, you probably want something like an arduino or another microcontroller kit -- something where you can run bare-metal without an OS. Depending on your platform, this experience may or may not be super-transferable to larger devices if that's a goal; for example, many small microcontrollers have no caches (or very simple caches), and CPU clock-speeds low enough that RAM access is essentially single-cycle -- which is not at all true of PCs or even many higher-end microcontrollers. The Pi makes another showing here -- Its reasonably documented now, and I've seen material on programming it bare-metal-style; the only downside is that its a lot to try to understand and in many ways its more accurate to say that the Pi's SOC is a GPU that happens to have a CPU, rather than the other way around. For my money, the Gameboy Advance is a good platform in this space -- Its very well-documented by the homebrew community, tools are readily available (emulators are a great resource), the hardware capabilities are interesting but not overwhelming in complexity or number. Bonus: you can distribute what you create as a ROM if you're interested in creating complete games, or even play on a real GBA.

Going full-retro, its hard to recommend against the C64 (6502) or Amiga (if you want to go 68k) -- either are very interesting, very capable, and very well-documented machines with communities that are still going strong. For their times, either one can be said to be a paragon of hardware design not just for how much they were capable of, but for how elegantly they achieved it.

throw table_exception("(? ???)? ? ???");

I vote 68000. I learned to program on a Mac 512KE and the only processor I've actually learned assembly for was the 68000. It has a remarkably easy and rather nice instruction set.

I'll throw in a vote for x86 through VS. In addition to what's been said, it gives you the opportunity to fiddle with C/C++ and see how the stack and function calls work. Also, I think that if you just pick something accessible and jump right in then you'll get the basics down and you can expand from there in whatever direction you please.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.


I'll throw in a vote for x86 through VS. In addition to what's been said, it gives you the opportunity to fiddle with C/C++ and see how the stack and function calls work.

This is quite true, and I guess you could target DOSbox if worst came to worst.

-potential energy is easily made kinetic-


I'll throw in a vote for x86 through VS. In addition to what's been said, it gives you the opportunity to fiddle with C/C++ and see how the stack and function calls work.

This is quite true, and I guess you could target DOSbox if worst came to worst.

?

Desktop PCs run x86 natively.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

Get yourself a Raspberry Pi2B or a BeagleBone Black. These are ARM boards -- the ARM processor is way simpler than the x86 even though they're of the same relative vintage (ARM is RISC, x86 is Swiss Army knife). In addition to learning ASM, you can futz with blinkenlights so you can really feel close to the metal. Learn to love the smell of rosin-core solder, it's the smell of victory.

This is the way to go. Most of the other suggestions are useless - while Z80s, 6502s, 68ks are kinda cute to play with, they have no relevance to modern development or modern processor design. x86 is extremely useful and relevant but also complicated and psychotic. MIPS was relevant once and continues to be a popular university choice, and resources are readily available. The trouble is just that very few MIPS chips are out there and what is generally lives in highly constrained embedded systems so it's just not a very real-world skill.

ARM strikes a great balance of being a nice, modern design that is highly relevant to work today, but still fairly straightforward to learn.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This is the way to go. Most of the other suggestions are useless

Guess it depends what your goal is.

Since the OP said he was interested in retro dev, of course retro systems is what you suggest.

But, if the goal is to learn asm in general, then sure, ARM is a great place to start. Don't need to get a raspberry though, you probably have one in your phone already.

And if you want to get really close to metal, then you could get a Teensy (cheap arduino-compatible with ARM)

Though I guess you have more hardware to play with in the Pi :)

The 68k is a very clean instruction set; you have a number of data registers, which all work the same, and address registers. There are nice instructions for math, including integer division / multiplication.

If your eventual goal is Megadrive and as you have previous C/C++ experience it doesn't seem like a stretch to go directly for the 68k.

However, there may be some difficulty in setting up a development toolchain so you can compile and run Megadrive programs, and also you would be learning the hardware features at the same time (to e.g. learn what addresses you need to poke to get something to show up on the screen). There are reverse-engineered / leaked resources for this, but not as abundant as for retro computers. When an 8/16bit console boots up and starts executing your program, it typically starts from almost nothing, on the other hand a computer typically has the screen already displaying some sensible data (like text), and has ROM operating system routines to help you.

Therefore, for the quickest, hassle-free introduction into the retro/asm programming mindset with minimal setup and immediately visible effects I'd recommend the C64 as well. For example with the VICE emulator, you can break into the built-in debugger/monitor and write & run simple asm programs directly; no toolchain setup needed. The C64 CPU instruction set is extremely limited though, you have three primary registers (A,X,Y) which all are used differently and you can forget about more complex functions like multiplication - they don't exist and must be written manually using bit-shifting arithmetic.

If you don't feel overwhelmed by the prospect of learning the hardware and having to set its state up from scratch, you'll waste less time going directly for your target platform though.

Oh, and one more thing: I first learned all about computers using assembly language for the CARDIAC computer -- it was the early 1970s, there were no PCs. Seriously, you could do worse. It was easy enough for a 10-year-old to understand and serious enough to propel him on a successful career in the industry when the industry didn't yet exist.

Stephen M. Webb
Professional Free Software Developer

This topic is closed to new replies.

Advertisement