1. Write a program to implement the logic function “P1.4=P1.0∨(P1.1∧P1.2)∨P1.3” using bit manipulation instructions.
MOV C,P1.1
ANL C,P1.2
ORL C,P1.0
ORL C,P1.3
MOV P1.3,C
2. Write a program that jumps to the LABLE storage unit if the contents of accumulator A meet the following conditions. Assume the unsigned number is stored in A.
(1) A≥10; (2) A>10; (3) A≤10.
(1)
CJNE A,#10,NEXT
LJMP LABLE
NEXT:
JNC LABLE
(2)
CJNE A,#10,NEXT
LJMP NEXT2
NEXT:
JNC LABLE
NEXT2:
(3)
CJNE A,#10,NEXT
LJMP LABLE
NEXT:
JC LABLE
3. Write a program to check if there is data 55H in the RAM units 30H to 50H. If found, set the 51H unit to FFH; if not found, clear the 51H unit to 0.
MOV R0,29H
NEXT:
INC R0
CJNE R0,#51H,NEXT2
MOV 51H,#0FFH
AJMP OVER
NEXT2:
CJNE @R0,#55H,NEXT
MOV 51H,#0
OVER:
4. Write a program to count the number of occurrences of 0 in the RAM units 30H to 50H, and store the result in the 51H unit.
MOV R0,30H
MOV 51H,#0
NEXT:
CJNE @R0,#00H,NEXT2
INC 51H
NEXT2:
INC R0
CJNE R0,#51H,NEXT
5. There is a data block in external RAM that contains several characters and numbers, starting at the address SOURCE. The task is to transfer this data block to the internal RAM starting at DIST, ending when the character “$” is encountered (the $ should also be transferred, its ASCII code is 24H).
MOV DPTR,#SOURCE
MOV R0,#DIST
NEXT:
MOVX A,@DPTR
MOV @R0,A
INC DPTR
INC R0
CINE A,#24H,NEXT
6. In the internal RAM, the 30H and 31H units store a 16-bit binary number, with the high byte first and the low byte last. Write a program to compute its complement and store it back in the original place.
CLR C
MOV A,#0
SUBB A,31H
MOV 31H,A
MOV A,#0
SUBB A,30H
MOV 30H,A
7. There are two 4-byte compressed BCD numbers stored in the internal RAM, one in the 30H to 33H units and the other in the 40H to 43H units. Write a program to add them, storing the result in BCD format in the 30H to 33H units.
CLR C
MOV R0,#30H
MOV R1,#40H
MOV R2,#4
NEXT:
MOV A,@R0
ADDC A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R2,NEXT
8. Write a program to transfer the 16-byte data stored in external RAM starting from 2000H to the internal RAM starting from 30H.
MOV DPTR,#2000H
MOV R0,#30H
MOV R1,#0
NEXT:
MOVX A,@DPTR
MOV @R0,A
INC DPTR
INC R0
INC R1
CINE R1,#16H,NEXT
This article is reprinted from the Internet, copyright belongs to the original author. If you find it inappropriate, please contact us for removal!
Advertisement
About Lichuang Mall
Lichuang Mall (WWW.SZLCSC.COM) was established in 2011, dedicated to providing customers with one-stop online procurement services for electronic components, leading in transaction volume nationwide. It has more than 10,000 square meters of modern component warehouse, with over 100,000 kinds of stock inventory. The group’s electronic full industry chain self-operated services include: online EDA (LCEDA) + industry-leading PCB prototyping/small batch + component mall + stencil manufacturing + SMT patch + electronic design education and solutions. As a vertical mall with a complete variety, self-operated inventory, and guaranteed quality of electronic components, all components in Lichuang Mall are purchased from regular channels of original manufacturers or agents, ensuring genuine products and providing you with professional one-stop component procurement services.