Open In App
Related Articles

Data Transfer instructions in AVR microcontroller

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Data transfer instructions are the instructions that 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 is 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 immediately given register. consider an example where the given Data is 05 and you have to load data to the accumulator. 

Example:

MVI A, 05

The following table shows different transfer instructions :

InstructionOperandExplanationExample
MOVD, SD = SMOV D, S
LDSD, K(memory location)D = Value at KLDS D, K
LDD, SD = Value at memory location stored in SLD D, S
LDID, K(constant)D = KLDI D, K
LPMD, Z(flash memory)Store the value in register Z from flash memory into the memory location stored in the D registerLPM D, Z
IND, AStores the value in register A in D. where A is from [0, 63](64 I/O Registers)IN D, A
OUTA, DStores the value in register D in A. where A is from [0, 63](64 I/O Registers)OUT A, D
STSK, SStores the value in register S into memory location K.STS K, S
STD, SStore the value in register S into the memory location stored in the D registerST D, S
PUSHDPushes the content of D on the top of the stackPUSH D
POPDRemoves the topmost entry from the stack and transfers that value to DPOP D

D and S are registers. PUSH and POP instructions are strict to maintain the stack.

 Features of the data transfer instructions in AVR microcontrollers:

  1. Load and Store instructions: AVR microcontrollers use a set of Load and Store instructions to transfer data between registers and memory. The Load instructions are used to move data from memory to registers, while the Store instructions are used to move data from registers to memory.
  2. Immediate instructions: AVR microcontrollers also support immediate instructions, which allow data to be loaded directly into a register without first storing it in memory. This can be useful for initializing variables or performing simple arithmetic operations.
  3. Addressing modes: AVR microcontrollers support a variety of addressing modes for data transfer instructions, including direct, indirect, indexed, and relative addressing. These modes allow data to be accessed from different memory locations and with different levels of indirection.
  4. Byte and Word transfer: AVR microcontrollers support both byte and word transfer instructions, allowing data to be transferred in either 8-bit or 16-bit chunks. This provides flexibility in how data is stored and accessed.
  5. Stack instructions: AVR microcontrollers also provide a set of stack instructions for managing the stack, which is a special area of memory used for storing temporary data and return addresses. These instructions allow data to be pushed onto and popped off of the stack.

Last Updated : 05 Apr, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads