Professional Documents
Culture Documents
8051 Data Transfer Instructions 4.8: Subject: Microcontroller & Interfacing
8051 Data Transfer Instructions 4.8: Subject: Microcontroller & Interfacing
Microcontroller &
Interfacing
Title:
8051 Data Transfer Instructions
Experiment No.
04
4.8
Rev. No.
DOC. CODE
AITS/ECD/EXPT
DATE:
1.00
Function
Rr A
MOV A,add
(add) A
MOV A,@RP
(RP) A
MOV A,#n
n A
MOV R,A
A Rr
MOV Rr,add
(add) Rr
MOV Rr,#n
n Rr
MOV add,A
A (add)
MOV add,Rr
Rr (add)
MOV add,@RP
RP (add)
Description
Copy data from register Rr to
Accumulator.
Copy data from given memory
location to the accumulator.
Copy data from memory location to
accumulator, whose address is given
by RP.
Copy immediate data n to
accumulator.
Copy data from Accumulator to
register Rr.
Copy data from given memory
location to register Rr.
Copy immediate data n to register Rr.
Copy data from the accumulator to
given memory location.
Copy data from register Rr to
given memory location.
Copy data from address given by RP
to given memory location.
Bytes
1
Cycles
1
Subject:
Microcontroller &
Interfacing
Title:
8051 Data Transfer Instructions
Experiment No.
04
n (add)
MOV add1,add2
(add2) (add1)
MOV @RP,A
A (RP)
MOV @RP,add
(add) (RP)
MOV @RP,#n
#n (RP)
MOV DPTR,#nn
nn DPTR
Rev. No.
DOC. CODE
AITS/ECD/EXPT
DATE:
MOV add,#n
4.8
1.00
3
Function
(A+PC) A
MOVC A,@(A+DPTR)
(A+DPTR) A
Description
Copy the code byte, found at
the address (A+PC) to
Accumulator
Copy the code byte, found at
the address (A+DPTR),to
Accumulator
Bytes
1
Cycles
2
Bytes
1
Cycles
2
Function
(DPTR) A
MOVX @DPTR,A
A (DPTR)
MOVX A,@RP
(RP) A
MOVX @RP,A.
A (RP)
Description
Copy the contents of the external RAM
address in DPTR to Accumulator.
Copy data from the Accumulator
to external RAM address in DPTR.
Copy the contents of the external RAM
address in RP to Accumulator.
Copy data from the Accumulator
to external RAM address in RP.
Function
(SP) (add)
Description
Copy the data from internal RAM
Bytes
2
Cycles
2
Subject:
Microcontroller &
Interfacing
Experiment No.
04
PUSH add
Title:
8051 Data Transfer Instructions
Rev. No.
DOC. CODE
AITS/ECD/EXPT
DATE:
(add) (SP)
4.8
1.00
Function
A Rr
XCH A,add
A (add)
XCH A,@RP
A (RP)
XCHD A,@RP
Alsn (RP)lsn
Description
Exchange data bytes between register Rr
and accumulator.
Exchange data bytes between add and
accumulator.
Exchange data bytes between
accumulator & contents of memory
location (address given by RP).
Exchange lower nibble between
Accumulator & contents of memory
location (address given by RP).
Bytes
1
Cycles
1
Subject:
Microcontroller &
Interfacing
Experiment No.
04
Title:
8051 Data Transfer Instructions
DATE:
DOC. CODE
AITS/ECD/EXPT
4.8
Rev. No.
1.00
EXERCISE: 1. Write a program to copy Immediate data AAH into registers R4, R5, & R6 of bank 2 using at least
four different methods.
2. Place the number 3Bh in internal RAM locations 30h to 32h.
3. Exchange the contents of the SP and the PSW.
4. Copy the byte at internal RAM address 27h to external RAM address 27h.
5. Set timer 1 to A23Dh.
6. Copy the data in external RAM locations 0123h to TL0 and the data in external RAM location 0234h
to TH0.
7. Set the SP register to 07h and PUSH the SP register on the stack; predict what number is PUSHed to
address 08h.
PROGRAM
org 00h
mov sp,#07h
push 81h
end
OUTPUT:
8. Rotate the bytes in registers R0 to R3: copy the data in R0 to R1, R1 to R2,
R0.
org 00h
MOV R0,#10H
MOV R1,#11H
MOV R2,#12H
MOV R3,#13H
MOV A,R3
XCH A,R0
XCH A,R1
XCH A,R2
ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT
R2 to R3, and R3 to
Subject:
Microcontroller &
Interfacing
Experiment No.
04
Title:
8051 Data Transfer Instructions
DATE:
DOC. CODE
AITS/ECD/EXPT
XCH A,R3
End
4.8
Rev. No.
1.00
Subject:
Microcontroller &
Interfacing
Experiment No.
04
Title:
8051 Data Transfer Instructions
DOC. CODE
AITS/ECD/EXPT
DATE:
Grade
Lab-In-Charge
ANSWERS
Ans.1
a) org 0000h
setb 0d4h
mov r4,#0aah
mov r5,#0aah
mov r6,#0aah
end
Uses 8 bytes of ROM
b) org 0000h
mov 14h,#0aah
mov 15h,#0aah
mov 16h,#0aah
end
Uses 9 bytes of ROM
c) org 0000h
setb 0d4h
mov a,#0aah
mov r4,a
mov r5,a
mov r6,a
end
Uses 7 bytes of ROM
Ans.2
4.8
a) org 0000h
mov 30h,#03bh
mov 31h,#03bh
mov 32h,#03bh
end
Uses 9 bytes of ROM
ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT
H.O.D.
Rev. No.
1.00
Subject:
Microcontroller &
Interfacing
Experiment No.
04
Title:
8051 Data Transfer Instructions
DOC. CODE
AITS/ECD/EXPT
DATE:
b) org 0000h
mov a,#3bh
mov 31h,a
mov 32h,a
mov 30h,a
end
Uses 7 bytes of ROM
Ans.3
org 0000h
mov psw,#0abh
xch a,psw
xch a,sp
xch a,psw
end
org 0000h
mov sp,#07h
push 81h
end
@08h = 07h
Ans.8
org 0000h
ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT
4.8
Rev. No.
1.00
Subject:
Microcontroller &
Interfacing
Experiment No.
04
Title:
8051 Data Transfer Instructions
DATE:
mov r4,r3
Mov r3,r2
Mov r2,r1
Mov r1,r0
Mov r0,r4
end
Ans. 9 org 0000h
mov dptr,#7dh
movC a,@(a+dptr)
mov sp,a
end
Ans.10
org 0000h
mov dptr,#02h
mov a,#00h
movc a,@a+dptr
mov dptr,#0300h
movx @dptr,a
end
DOC. CODE
AITS/ECD/EXPT
4.8
Rev. No.
1.00
Subject:
Microcontroller &
Interfacing
Experiment No.
04
Title:
8051 Data Transfer Instructions
DATE:
end
DOC. CODE
AITS/ECD/EXPT
4.8
Rev. No.
1.00