Dark Mode
Image

COA_Misc

Data transfer instruction in AVR microcontroller

The data transfer instruction is used to transfer the data into the microcontroller. It is used to copy the data from source to destination simply. The data transfer instructions are also known as the copy instructions.

With the help of these instructions, we can transfer the data from the following:

Register to Register

The data is transferred into destination register from source register in the register to register data transfer. Now we will describe an example of binary additional.

OOPs Concepts in Java

Example: We have a register B and Accumulator register A in this example. Firstly, we have to transfer the data into register B, and after that, the data will be transferred from register B to A. The instructions to transfer it are described as follows:

  1. MVI B, 05  
  2. MOV A, B  

Register to Memory

The data is transferred into the given memory location from the register in this data transfer mode. Now we will describe an example with the help of memory location 201k and accumulator register A. In this example, we have to copy the data into location 201k from the accumulator. The instruction to do this is described as follows:

  1. STA 201k  

Memory to Register

The data is transferred into the register from memory in the memory to register data transfer. Here, we will describe an example with the help of memory location 201k and accumulator register A. In this example, we have to load the data into the accumulator from location 201k. The instruction to do this is described as follows:

  1. LDA 2020k  

Constant to Register

The data is transferred into the immediately given register in the constant to register data transfer. Now we will describe an example with the help of memory data '05' and accumulator register A. In this example, we have to load the given data into the accumulator. The instruction to do this is described as follows:

  1. MVI A, 05  

Now we will describe a table to show the various types of transfer instructions and their explanation:

Instruction Operand Explanation Example
MOV D, S This instruction is referred to as copy register. The MOV instruction is used to make a copy of the content of one register into another register. We will make a copy of S into D. Here D is the destination register and the register S is the source register. The S is unchanged register, and D register is loaded with a copy of S. The syntax of MOV instruction is described as follows:
D = S
MOV D, S
LDS D, K (memory location) The LDS instruction is referred to as the Load Direct from Data Space. This instruction is used to load one byte from data space into the Destination register D. The syntax of LDS instruction is described as follows:
D = Value at K
LDS D, K
LD D, S The LD instruction is referred to as the Load Indirect from Data Space. This instruction is used to indirectly load the value at memory location stored in S into the Destination register D. The syntax of LD instruction is described as follows:
D = Value at memory location stored in S
LD D, S
LDI D, K (constant) The LDI instruction is referred to as the Load Immediate. This instruction is used to load an 8-bit constant directly into the destination register 16 to 31. The syntax of LDI instruction is described as follows:
D = K
LDI D, K
LPM D, Z (flash memory) The LPM instruction is referred to as the Load Program Memory. The LPM instruction is used to load one byte, which is pointed by the Z register into the D. Here, D is the destination register. The feature of this LPM instruction is 100% space-efficient constant data fetch or constant initialization. The syntax of LPM instruction is described as follows:
D = Z
LPM D, Z
IN D, A The IN instruction is referred to as Load an I/O Location to register. The IN instruction is used to load the data of I/O space (Timer, Ports, Configuration Registers, etc.) into the destination register D in a register file. The syntax of IN instruction is described as follows:
D = I/O(A)
IN D, A
OUT A, D The OUT instruction is = referred to as Store Register to I/O Location. The OUT instruction is used to store the data of register D in the register file to I/O space (Timers, Ports, Configuration Registers, etc.) The syntax of MULSU instruction is described as follows:
I/O(A) = D
OUT A, D
STS K, S The STS instruction is referred to as Store Direct to Data Space. The STS instruction is used to store the one-byte data into the memory location K from the register S. Here S is the Source register. The syntax of STS instruction is described as follows:
K = S
STS K, S
ST D, S The ST instruction is referred to as Store Indirect From Register to Data Space. The ST instruction is used to indirectly store the one-byte data into the memory location stored in register D from register S. Here, S is the source register, and D is the destination register. The syntax of ST instruction is described as follows:
D = S
ST D, S
PUSH D The PUSH instruction is referred to as Push Register on Stack. This register is used to store the content of register D on the STACK. After the PUSH operation, the Stack pointer will be post decremented by 1. The syntax of PUSH instruction is described as follows:
STACK = D
PUSH D
POP D The POP instruction is referred to as Pop Register from Stack. This register is used to load one byte from the STACK into register D. Before POP operation, the Stack pointer will be pre-incremented by 1. The syntax of POP instruction is described as follows:
D = STACK

Comment / Reply From