Electronic – a Good Starter Microprocessor to learn Assembly

assemblymicrocontrollermicroprocessor

So I'm wanting to learn Assembly first on an MP, then move onto C (since it seems like that's what most of them use).

I'm wanting to get into Embedded Programming, I really love low level C stuff (Kernels/Modules for Linux is mainly what I've done), but I love the idea of being able to program even lower level than that (Microcontrollers/Microprocessors).

I know about Arduino, and that's great and all, but I can't find many resources for using Assembly with them. Atmel AVRs seem to be very popular (and cheap), but when it comes to the actual hardware portion (hooking them up on a breadboard, etc.), I'm not finding much information.

Any suggestions/information or resources that you guys/gals know about please let me know.

Edit: Another thing:
It seems like all the Microprocessor books I read (Usually AVRs) talk about the microprocessor itself, and programming it. But I have yet to see a book that actually talks about installing all the components yourself (microprocessor, memory, power, etc.). If I could find something that walks me through that I'd be in business. (I want to learn from the ground up.) Not to mention I have no idea how you would communicate between them.

Best Answer

I learned on a 68HC11 in college. They are very simple to work with but honestly most low powered microcontrollers will be similar (AVR, 8051, PIC, MSP430). The biggest thing that will add complexity to ASM programming for microcontrollers is the number and type of supported memory addressing modes. You should avoid more complicated devices at first such as higher end ARM processors.

I'd probably recommend the MSP430 as a good starting point. Maybe write a program in C and learn by replacing various functions with inline assembly. Start simple, x + y = z, etc.

After you've replaced a function or algorithm with assembly, compare and contrast how you coded it and what the C compiler generated. This is probably one of the better ways to learn assembly in my opinion and at the same time learn about how a compiler works which is incredibly valuable as an embedded programmer. Just make sure you turn off optimizations in the C compiler at first or you'll likely be very confused by the compiler's generated code. Gradually turn on optimizations and note what the compiler does.

RISC vs CISC

RISC means 'Reduced Instruction Set Computing' it doesn't refer to a particular instruction set but just a design strategy that says that the CPU has a minimal instruction set. Few instructions that each do something basic. The is no stringently technical definition of what it takes 'to be RISC'. On the other hand CISC architectures have lots of instructions but each 'does more'.

The purposed advantages of RISC are that your CPU design needs fewer transistors which means less power usage (big for microcontrollers), cheaper to make and higher clock rates leading to greater performance. Lower power usage and cheaper manufacturing are generally true, greater performance hasn't really lived up to the goal as a result of design improvements in CISC architectures.

Almost all CPU cores are RISC or 'middle ground' designs today. Even with the most famous (or infamous) CISC architecture, x86. Modern x86 CPUs are internally RISC like cores with a decoder bolted on the front end that breaks down x86 instructions to multiple RISC like instructions. I think Intel calls these 'micro-ops'.

As to which (RISC vs CISC) is easier to learn in assembly, I think its a toss up. Doing something with a RISC instruction set generally requires more lines of assembly than doing the same thing with a CISC instruction set. On the other hand CISC instruction sets are more complicated to learn due to the greater number of available instructions.

Most of the reason CISC gets a bad name is that x86 is by and far the most common example and is a bit of a mess to work with. I think thats mostly a result of the x86 instructions set being very old and having been expanded half a dozen or more times while maintaining backward compatibility. Even your 4.5Ghz core i7 can run in 286 mode (and does at boot).

As for ARM being a RISC architecture, I'd consider that moderately debatable. Its certainly a load-store architecture. The base instruction set is RISC like, but in recent revisions the instruction set has grown quite a bit to the point where I'd personally consider it more of a middle ground between RISC and CISC. The thumb instructions set is really the most 'RISCish' of the ARM instruction sets.

Related Topic