1: General Purpose Registers
2: Status Register (SREG) – contains info about result of last executed instruction
3: Program Counter (PC) – Address of next instruction
4: Instruction Register (IR) – Holds fetched instruction
5: Stack Pointer (SP) – Points to top of stack
Stack
The Stack is mainly used for storing temporary data for
local variable
return addresses after interrupts and subroutine calls.
Implemented as growing from higher to lower memory locations.
Initial Stack Pointer is set equal to the last address of the internal SRAM
PUSH command will decrease the SP.
POP command will increase the SP.
Note Table 6-1. from data sheet has all assembly Stack Pointer instructions.
Stack Pointer - SP
Points to top of the stack
Implemented as two 8-bit registers
What does address in SP tell us?
SP implementation in AVR
Status Register SREG
Status Register (SREG):
contains information about the result of the most recently executed instruction
can be used to altering program flow via conditional operations
save/restore must be handled by software for interrupt calls (not automatic in hardware)
Bit7:I: Global Interrupt Enable. Setting this bit enables all the interrupts. Resetting this disables all interrupts.
Bit6:T: Bit Copy Storage. Used with BLD (bit load) and BST (bit store) ISTR for loading and storing bits from one register to another.
Bit5:H. Half Carry Flag. Indicates half carry in some arithmetic ISTRs.
Bit4:S. Sign Flag. This bit is the exclusive OR between the negative flag N and the Overflow flag V.
Bit3:V. Two's Complement Overflow Flag.
Bit2:N. Negative Flag.
Bit1 :Z. Zero Flag. Indicates a zero result after an arithmetic or logical operation.
Bit0:C. Carry Flag. Indicates a carry in arithmetic or logical operation.
Register File
Most instructions have direct access to all registers
e.g. LD (load indirect from data space), MUL (multiply)