Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
3  
I hate to send you elsewhere, but if you're interested in AVRs you need to know about AVRfreaks.net. –  Kevin Vermeer Mar 30 '11 at 19:16
    
Ya Im leaning towards AVR...mainly because theirs SO much info about them, and they are ALOT cheaper than the TI-MPS430... –  Mercfh Mar 30 '11 at 21:37
2  
AVR is popular with hobbyists, but I'm not sure where you're getting your cost data. Both families have some offerings that are less than 1 USD and others pushing 20 USD. –  Kevin Vermeer Mar 30 '11 at 22:12
    
Well.....when I was looking at the MPS430 it looked like the software (debuggers etc) were a bit expensive when added onto the development boards. –  Mercfh Mar 30 '11 at 22:20
1  
My advice is don't pick MSP430 if you're a beginner. The official tools are good, but the free support you'll find online doesn't match up to PIC/AVR –  Toby Jaffey Mar 31 '11 at 9:01
add comment

11 Answers 11

up vote 13 down vote accepted

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.

share|improve this answer
    
@Mark - ARMs are also RISC processors, the instruction set isn't that bad. It's actually quite nicely designed; there are some instructions for userspace vs. kernelspace differentiation and other complexities, but those can be ignored while you're starting out. –  Kevin Vermeer Mar 30 '11 at 19:21
1  
@reemrevnivek I was more trying to steer him away from the complexities of dealing with multiple processor modes and MMUs as he started into ASM which why I mentioned higher end ARMs. The initialization and setup of higher end ARM SoCs is also substantially more complex than something like an AVR/PIC/MSP430. –  Mark Mar 30 '11 at 19:33
    
RISC? im not sure I understand the difference between that and whatever the others are... care to explain? Aren't most Microcontrollers RISC? it just means less instruction sets correct? –  Mercfh Mar 30 '11 at 21:12
1  
@sauron I added to my answer re:RISC vs CISC. –  Mark Mar 30 '11 at 21:49
    
Are stuff like AVR's/PICS usually RISC or CISC? –  Mercfh Mar 31 '11 at 15:06
show 4 more comments

I think 8 bits PIC microcontrollers are the best choice because of the reduced number of instructions.

The side effect of the reduced number of instructions is that you have to reinvent the wheel compared with other microcontrollers with more instructions.

But after learn with PIC, you can migrate to other microcontrollers and see whats fits better for you.

share|improve this answer
    
I wouldn't totally disagree as this is what I am exploring now, but 8, 16, and 32 bit cores have totally different asm strategies. –  Grady Player Feb 22 '13 at 6:45
add comment

Similar to Mark's suggestion of the 68HC11, The instruction set of the Freescale 68HCS08 family is a slimmed-down version of the Motorola 6809, which I thought had one of the cleanest 8-bit instructions sets of its time. You can get a development board with switches, LED's, 3-axis accelerometer and piezo buzzer for $79 here.

share|improve this answer
    
The reduced number of registers the S08 has versus the HC11 can make things a little more difficult up front, as you'll need to figure out the stack do to much of anything (which was taught later in my lab with HC11s (or was it 12's)). By extension, AVRs are really nice because you have a whopping 32 registers to play with before worrying about the stack. –  Nick T Mar 31 '11 at 3:01
    
Actually I like the simplicity of the single accumulator, even though it can be a bottleneck. Instead of using the stack for temp variables, to start with I find it simpler to use the 144 bytes of direct page variables which are accessible with shorter instructions (the other 112 bytes of direct page are used for I/O registers). Using the stack (which allows for reentrant and recursive routines) can be learned later. –  tcrosley Mar 31 '11 at 5:15
    
+1 for praising the 6809! –  stevenvh Mar 31 '11 at 6:47
    
Wasn't the HC(S)08 derived from the HC05? –  Johan.A Aug 8 '13 at 8:42
    
@Johan.A Yes, you are absolutely right. The HCS08 is an enhanced version of the HC05. I should have mentioned that. I think the derivation is something like 6800 -> 6801 -> 6805 -> HC(S)08. I wrote a lot of assembly code for the 6805. I compared the HCS08 to the 6809 to tie in with the other comments re the 68HC11 (which is roughly a microcontroller version of the 6809). –  tcrosley Aug 8 '13 at 14:41
add comment

The msp430 instruction set is a good one for learning assembler on. Avoid x86. Arm is another good one but has a lot more instructions and options and may not be best suited as a first instruction set. Thumb is a subset of the arm instruction set and not bad, on github I have both a thumb emulator (thumbulator) and an msp430 emulator (not tested as much as the thumb one) that are barebones, just the processor and memory and little more, so you can get good visibility into what is going on. An alternative would be qemu for example where the visibility is there but much harder to get at, likewise with a qemu like solution it takes a lot more work before you figure out if you have anything working.
goto mspgcc4.sf.net to build a toolchain, and/or a stock binutils (./configure --target=msp430 --prefix=/something) in combination with a stock llvm. Once you are ready for hardware an msp430 development board costs under 5 dollars. For arm/thumb tools just get the lite version from codesourcery. A cortex-m3 (thumb/thumb2) board is about 12 bucks right now. I would avoid x86 and avr and others as a first instruction set, you will want to learn others to be well rounded. The old/original pic instruction set is something worth looking at as well. You could write a simulator yourself in an afternoon for it as well as learn the assembler. I wouldnt learn it first necessarily, it does teach some interesting things, but at the same time doesnt scale and isnt necessarily representative of common features you find in most instruction sets. The msp430 gave me the feel of the pdp11 which is the first instruction set I really learned, both have well rounded, mostly orthogonal features. Both the msp430 and microchip pic instruction sets are documented at wikipedia, at least as a reference, to get the whole picture get the datasheets/manuals from the vendors which will describe each register and addressing mode, reset/boot, etc.

share|improve this answer
    
for assembler only you only need binutils, at least for arm/thumb or msp430, and you can build the assembler and linker. If you want a C compiler from which you can examine the assembler output as a learning tool, then you need mspgcc4 or codesourcery or just use llvm for both. –  dwelch Mar 31 '11 at 3:11
add comment

Are you sure you want to learn Assembly? Can you say why? It is quite a task, and is less and less relavent or useful now a days. This is from a person who has written in it and even hand assembled programs ( no assembler, linker, just a card with the instruction set ).

share|improve this answer
    
This isn't really an answer, as much as a comment. I'd also be hesitant to trust an embedded C programmer who was unwilling to trudge through bits of assembly now and then when trying to understand an oddity in the behavior of a project. –  Chris Stratton Sep 19 '13 at 20:50
add comment

I too learned on a 68HC11 in college. Rather they suggest this over any other MPU/MCU, I just wanted to point out the the development board we used had a monitor program on it. So from a dumb terminal we could step through the code and examine the registers... I'd suggest when you know which processor fits your requirements you also check into what development boards are available with a monitor program.

share|improve this answer
    
The monitor program sounds like it'd be very helpful. What book did u use to learn this? if you mind me asking.... –  Mercfh Mar 31 '11 at 16:58
add comment

I learnt 16-bit PIC assembly with a dsPIC33F. The processor's assembly is quite C like, in that it supports pointers and three variable operations (A = B + C, for example), which makes learning and adapting to it much easier.

share|improve this answer
add comment

I teach both PIC (14-bit core) and ARM assembly. The PIC class I tell that once they have mastered the uglyness of that architecture they can take on anything else. The ARM (not the Thumb/Cortex!) is a very nice architecture to learn assembly. We use an LPC2148 board.

share|improve this answer
    
Hi Wouter, it's good to see you over here! –  Olin Lathrop Jun 28 '11 at 21:59
add comment

You are confusing microcontrollers and microprocessors here. AVR is a microcontroller line by Atmel, not a microprocessor. I suggest you first search on wikipedia to get a better understanding of what the differences are between these. Basically a microcontroller is a more or less complete system, whereas a microprocessor is only the cpu (hence a microcontroller has a microprocessor inside).

share|improve this answer
    
Ya I knew that, I dunno why i didn't put that. I meant like not many guides talk about actually connecting a MP and Memory (like flash or eeprom) etc... –  Mercfh Mar 30 '11 at 18:12
1  
Since most microprocessors now have cache/memory and some I/O, it's a very blurry line. –  kenny Mar 30 '11 at 19:05
1  
@Sauron - You sure you knew that? You used MP again; a microcontroller (which is the correct term for an AVR and 99% of the devices we discuss here) almost always has memory (both non-volatile, like EEPROM and Flash, and volatile SRAM) on-board. Learn to use the onboard stuff before you start venturing into peripherals. –  Kevin Vermeer Mar 30 '11 at 19:19
add comment

At my university, we were taught hardware design/architecture alongside assembly language (the two go hand in hand, obviously) with the MIPS (or perhaps DLX) architecture. Since then, I've dabbled in PIC and AVR assembly a little bit at school/work, and they are all pretty similar. I think MIPS assembly was a great starting point, since the language is very simple, as is the processor architecture.

See also: this book. Not the best book in the world, but it's the standard computer design book for a lot of universities.

share|improve this answer
add comment

my suggestion is any one who is going to start studying about microcontrollers and processors should read the book naming "code the hidden language of computer" if you study that almost you are expert with processors and for programming avr better use poney prog programmer and program from atmel studio6.1 from atmel official site

share|improve this answer
    
Please outline the key features of the book and the programmer, that would incline the OP to use exactly them. –  Vorac Sep 19 '13 at 15:00
    
it is about understanding a microcontroller how it is developed from digital systems and explains the assembly language –  avinash Sep 27 '13 at 3:14
    
go to this site j.mp/mpcinterest to get that book –  avinash Sep 27 '13 at 3:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.