AVR Revisited (Assembly)

AVR asm is going to come in handy pretty soon. I might need it to create a bootloader in the upcoming months. Here's a quick review.

AVR Registers are 8bit registers and are 32 in number. They go from R0 to R31. Out of which only registers from R16 to R31 are directly loadable with data. There are three pairs of registers that combine to give a 16 bit word length. They are X (R27:R26), Y (R29:R28) and Z (R31:R30). They are required to do operations like Memory Addressing since memory addresses are 16 bits each.

Bigger chips have RAMPX, RAMPY, RAMPZ, RAMPD and EIND that are used to create 24 bit word length registers used to address the extra memory space.

In the next few posts I am going to try and set out as many example problems as I can to show code. Here's one. Add two numbers. For the purpose of this example I am using Atmega88A. Lets add stuff.

.include "../m88Adef.inc"
.org 0
;setting the stack pointer
;only required for looping
OUT SPL, R16  

LDI R16, 14  
LDI R17, 15  
ADD R16, R17  
; Result in R16

See, really dumb example. But it's a review.