Skip to content
Related Articles

Related Articles

Improve Article

Data Transfer instructions in AVR microcontroller

  • Last Updated : 22 Sep, 2020

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 :

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 D
POP D

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

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :