MOV Rl,#40H MOV R2,#08H MOV R3,#00H MOV R4,#00H
CHODEV: MOVX A,@DPTR
MOV R5,A ANL A,#0lA JNZ DD MOV A,R5 MOV @R0,A INC R0 INC R3 SJMP NEXT
DD: MOV A,R5
MOV @Rl,A INC R1 INC R4
NEXT: INC DPTR
DJNZ R2,CHODEV MOV R0,#30H MOV Rl,#40H
EVMOV: MOV A,@R0
MOVX @DPTR,A INC R0
INC DPTR
DJNZ R3,EVMOV ODMOV: MOV A,@Rl MOVX @DPTR,A INC R1 INC DPTR
DJNZ R4,ODMOV HERE: SJMP HERE ORG 7000H
BLOCK DB 69H,47H,32H,61H DB 56H,49H,27H,78H BUFFERl DS 3 BUFFER2 DS 5
3·2·43 阅读下列程序,写出程序执行后片外RAM8003H和8005H单元以及DPTR、R2,R0的内容。
ORG 0200H
START: MOV R0,#30H
MOV Rl,#30H MOV R2,#2
MOV DTPR,#BUFFER
HETOAS: MOVX A,@DPTR
MOV R3,A SWAP A
ANL A,#0FH ADD A,#90H DA A
ADDC A,#40H DA A
MOV @Rl,A INC R1 MOV A,R3 ANL A,#0FH ADD A,#90H DA A
ADDC A,#40H DA A
MOV @Rl,A INC DPTR INC R1
DJNZ R2,HETOAS MOV R2,#4 LOOP: MOV A,@R0 MOVX @DPTR,A INC R0 INC DPTR DJNZ R2,LOOP HERE: SJUMP HERE ORG 8000H BUFFER DB 2AH,49H BLOCK DS 4 END 3·2·44 阅读下列程序,写出程序执行后片外RAM 2002H和 200l3H单元以及DPTR、SP、R3的内容。
注意: 本程序在RESET后执行 ORG 0100H
MOV DPTR, #DAT MOVX A, @DPTR MOV R0, A SWAP A
ANL A, #0FH ACALL BTOA MOV R4, A MOV A, R0 ANL A, #0FH
ACALL BTOA MOV R5, A INC DPTR MOVX A, @DPTR MOV Rl, A SWAP A
ANL A, #0FH ACALL BTOA MOV R6, A MOV ANL ACALL MOV INC MOV MOVX INC MOV MOVX INC MOV MOVX INC MOV MOVX HERE: SJMP ORG BTOA: MOV MOV ORL LOP. RLC JNC INC NEXT: DJNZ RLC PUSH MOV JNB POP ORG SJMP CONT: POP GONE: RET
ORG A, Rl A, #0FH BTOA R7, A DPTR A,R4
@.DPTR,A DPTR A.R5
@DPTR,A DPTR A,R6
@DPTR,A DPTR A,R7
@ DPTR,A HERE 0200H R2,#08H R3,#00H A.#30H A NEXT R3
R2,LOP A ACC A,R3
ACC.O,CONT ACC A,#80H GONE ACC 2000H
DAT: DW 7954H DW 0000H DW 0000H END ·· 共 ·
3·2·45 阅读下列程序 写出程序执行后片外 RAM 8000H和 8002H单元以及Rl、R3、R4的内容。
ORG 0200H
MOV DPTR,#DAT MOV R0,#0 MOV Rl,#1 MOV R2.#2
MOVX A,@DPTR MOV R3,A INC DPTR
MOVX A,@DPTR
ORL A,R3 JZ HERE
MOV DPTR,#DAT
LOOPl: MOV R3,#8
LOOP2: MOVX A.@DPTR ANL A,Rl MOV R4,A JZ NEXT TNC R0
NEXT: MOV A.Rl
RL A MOV Rl.A
DJNZ R3,LOOP2 INC DPTR DJNZ R2,LOOPl MOV A,R0
MOVX @DPTR,A HERE: SJMP HERE ORG 8000H
DAT: DW 4B9FH
DB 0 END
3·2·46阅读下列程序,设fOSC=l2MHz,请回答:
(1)该程序每隔多少时间执行一次检测程序?是怎样安排达到的? (2)定/计0及定/计1各在什么情况下溢出?列出您的计算。 (3)为程序作出注释。
0000H LJMP 0030H ;主程序
ORG 0030H START: CLR Tl
MOV TMOD,#5lH MOV IE,#8AH MOV TH0,#0D8H
MOV TL0,#0F0H MOV THl,#0E8H MOV TLl,#90H SETB TR0 SETB TR1
; ;
;中断服务程序
ORG 000BH LJMP 0080H ORG 0080H
TOOV: SETB T1
MOV TH0,#0DBH MOV TL0,#0F0H CLR T1 RETI
ORG 00lBH LJMP 0090H ORG 0090H
T1OV: MOV THl,#0E8H
MOV TLl,#90H
;
; ;此起为检测程序 ; RETI
3·2·47阅读本书实验部分第3章\实验五P0口扩展I/O 口\参考程序中自指令MOV TMOD,#50H起的程序,仔细钻研其中定时器/计数器0、定时器/计数器l、R6、R7的用法,写出您的理解、分析与计算。 3·2·48阅读参考书籍,钻研MCS—51系列单片机在怎样的情况下才能单步执行用户程序?