Data Transfer instructions in AVR microcontroller
Data transfer instructions are the instructions which are used to transfer data into micro-controller.
These instructions can be used to transfer data from :
- Register to Register :
In register to register transfer, data transfer from one register to another register. Consider an example where you have to perform binary addition.
Example –
In this example first data will transfer to B register and after that It will transfer from B register to Accumulator register.MVI B, 05 MOV A, B
- Register to Memory :
In this data transfer, Data will be transferred from register to the given memory location. consider an example where given location is 201k and you have to copy data from the accumulator.
Example –STA 201K
- Memory to Register :
In this data transfer, Data will be transferred from memory to the register. consider an example where given location is 201k and you have to load data from this memory location to the accumulator.
Example –LDA 2020k
- Constant to Register :
In this data transfer, Data will be transferred to the immediate given register. consider an example where given Data is 05 and you have to load data to the accumulator.
Example –MVI A, 05
The following table shows different transfer instructions :
Instruction | Operand | Explanation | Example |
---|---|---|---|
MOV | D, S | D = S | MOV D, S |
LDS | D, K(memory location) | D = Value at K | LDS D, K |
LD | D, S | D = Value at memory location stored in S | LD D, S |
LDI | D, K(constant) | D = K | LDI D, K |
LPM | D, Z(flash memory) | Store the value in register Z from flash memory into the memory location stored in the D register | LPM D, Z |
IN | D, A | Stores the value in register A in D. where A is from [0, 63](64 I/O Registers) | IN D, A |
OUT | A, D | Stores the value in register D in A. where A is from [0, 63](64 I/O Registers) | OUT A, D |
STS | K, S | Stores the value in register S into memory location K. | STS K, S |
ST | D, S | Store the value in register S into the memory location stored in the D register | ST D, S |
PUSH | D | Pushes the content of D on the top of the stack | PUSH D |
POP | D | Removes the topmost entry from the stack and transfers that value to D | POP D |
D and S are registers. PUSH and POP instructions are strictly to maintain the stack.
Please Login to comment...