单片机读程序题题库答案_第1页
单片机读程序题题库答案_第2页
单片机读程序题题库答案_第3页
单片机读程序题题库答案_第4页
单片机读程序题题库答案_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、四、阅读以下程序,注释并填写指令执行后的结果每题10分1、 ORG 0 LJMP START ;跳转到PC0030H处 ORG 30HSTART:MOV R0,#20H ;20H>R0 (R0)=20H MOV R1,#30H ; #30H>R1 (R1)=30H MOV A,R0 ;(R0)>A (A)=20H ADD A,#36H ;(A)+#36H>A (A)=56H MOV P1,A ;(A)>P1 (P1)=56H INC R0 ;(R0)+1>R0 (R0)=21H INC R1 ;(R1)+1>R0 (R1)=31H ANL A,R1 ;

2、(A)&(R1)>A (A)=10H SWAP A ;累加器A的上下4位交换 (A)=01H PUSH ACC ;累加器A内容压栈 MOV P1,A ;(A)>P1 (P1)=01H POP B ;堆栈内容出栈到B存放器 (B)=01H MOV R0,A ;(A)>R0 (R0)=01H MOV DPTR,2200H ;#2200H>DPTR (DPTR)=2200H SETB C ;1>Cy (Cy)=1 ADDC A,0 ;(A)+0+(Cy)>A (A)=02H MOVX DPTR,A ;(A)>(DPTR) (2200H)=02H EN

3、D(R0)= 01H (R1)= 31H (P1)= 01H (B)= 01H (2200H)= 02H 2、 ORG 0 LJMP START ;跳转到(PC)=0030H处 ORG 30H START:MOV SP,#50H ;#50H>SP (SP)=50HMOV R2,#10H ;#10H>R2 (R2)=10H MOV DPTR,#3000H ;#3000H>DPTR (DPTR)=3000H CRL A ;0>A (A)=0 LOOP: MOVX DPTR,A ;(A)>(DPTR) INC DPTR ;(DPTR)+1>DPTR DJNZ R2

4、,LOOP ;(R2)-1>R2 假设(R2)不等于零那么转移到LOOP处 INC DPH ;(DPH)+1>DPH (DPH)=31H (R2)=00H (DPL)=10H INC DPH ;(DPH)+1>DPH (DPH)=32H MOV 20H,#36H ;#36H>(20H) (20H)=36H SETB 00H ;位地址00H置1 20H.0=1 (20H)=37H MOV A,20H ;(20H)>A (A)=37H MOVX DPTR,A ;(A)>(DPTR) (DPTR)=3210H (3210H)=37H INC A ;(A)+1>

5、;A (A)=38H INC A ;(A)+1>A (A)=39H PUSH ACC ;累加器A内容压栈 (SP)=51H XCH A,R2 ;累加器A的内容与R2内容互换 (A)=00H (R2)=39H POP DPH ;堆栈内容弹到DPH (DPH)=39H ADD A,#55H ;(A)+#55H>A (A)=55H PUSH ACC ;累加器A内容压栈 END(A)= 55H (R2)= 39H (20H)= 37H (DPTR)= 3910H (SP)= 51H 3、 ORG 0 LJMP START ;跳转到(PC)=0030H处 ORG 30HSTART:MOV R

6、0,#30H ;#30H>R0 (R0)=30H MOV A,#12H ;#12H>A (A)=12H SETB C ;(Cy)=1 ADDC A,R0 ;(A)+(R0)+Cy>A (A)=43H MOV R0,A ;(A)>(R0) (30H)=43H SWAP A ;累加器A上下4位交换 (A)=34H INC A ;(A)+1>A (A)=35H MOV DPTR,#2000H ;#2000H>DPTR (DPTR)=2000H INC DPH ;(DPH)+1>DPH (DPH)=21H MOV P1,A ;(A)>P1 (P1)=35

7、H INC A ;(A)+1>A (A)=36H MOVX DPTR,A ;(A)>(DPTR) (2100H)=36H XCH A,R0 ; (A)óR0 (A)=30H (R0)=36H RL A ;累加器A内容循环左移 (A)=60H PUSH ACC ;累加器A的内容入栈 RL A ;累加器A内容循环左移 (A)=0C0H POP ACC ;堆栈内容弹出到累加器A (A)=60H END(A)= 60H (R0)= 36H (DPTR)= 2100H (P1)= 35H (30H)= 43H 4、 ORG 0 LJMP START ;跳转到(PC)=0030H处

8、ORG 30H START: MOV SP,#50H ;#50H>SP (SP)=50H MOV DPTR,#3000H ;#3000H>DPTR (DPTR)=3000H MOV R0,#20H ;#20H>R0 (R0)=20H MOV A,#23H ;#23H>A (A)=23H MOV R2,#0FH ;#0FH>R2 (R2)=0FH SETB 01H ;置位20H.1 (20H.1)=1 SETB C ;置位Cy (Cy)=1 ADDC A,R0 ;(A)+(R0)+Cy>A (A)=26H INC R0 ;(R0)+1>R0 (R0)=2

9、1H MOV R0,A ;(A)>(R0) (21H)=26HLOOP: DJNZ R2, LOOP ;(R2)-1>R2 假设R2内容不等于零那么转移 SWAP A ;累加器A内容的上下4位交换 (A)=62H PUSH ACC ;累加器A内容入栈 INC DPH ;(DPH)+1>DPH (DPH)=31H MOVX DPTR,A ;(A)>(DPTR) (3100H)=62H POP B ;堆栈内容弹出到B (B)=62H RR A ;累加器A内容循环右移 (A)=31H ADD A,B ;(A)+(B)>A (A)=93H MOV P1,A ;(A)>

10、;P1 (P1)=93H END(21H)= 26H (R2)= 00H (A)= 93H (B)= 62H (3100H)= 62H 5、 ORG 0 LJMP START ;跳转到PC0030H处 ORG 30H START: MOV DPTR,#1000H ;#1000H>DPTR (DPTR)=1000H MOV A,#13H ;#13H>A (A)=13H MOV R0,#20H ;#20H>R0 (R0)=20H SETB C ;1>Cy (Cy)=1 MOV R0,A ;(A)>(R0) (20H)=13H RLC A ;累加器A的内容带进位循环左移

11、 (A)=27H XCH A,R0 ;累加器A的内容与20H单元的内容互换 (A)=13H (20H)=27H PUSH ACC ;累加器A的内容入栈 POP DPL ;堆栈内容弹出到DPL (DPL)=13H MOVX DPTR,A ;(A)>(DPTR) (1013H)=13H DEC A ;(A)1>A (A)=12H PUSH DPH ;DPH内容压栈 POP B ;堆栈内容弹出到B (B)=10H ADD A,B ;(A)+(B)>A (A)=22H MOV P1,A ;(A)>P1 (P1)=22H CLR A ;累加器A内容清零 ADD A,B ;(A)+

12、(B)>A (A)=10H END(P1)= 22H (B)= 10H (20H)= 27H (DPTR)= 1013H (R0)= 20H 6、 ORG 0 LJMP START ;跳转到PC0030H处 ORG 30H START:MOV SP,#50H ;#50H>SP (SP)=50H MOV R0,#20H ;#20H>R0 (R0)=20H MOV R2,#10H ;#10H>R2 (R2)=10H MOV A,#24H ;#24H>A (A)=24H LOOP: MOV R0,A ;(A)>(R0) INC R0 ;(R0)+1>R0 D

13、JNZ R2,LOOP ;(R2)-1>R2 假设R2内容不等于0那么跳转到LOOP处 SETB 00H ;1>位地址为00H的位 (20H.0)=1 (20H)=25H SETB C ;1>Cy (Cy)=1 ADDC A,#00H ;(A)+00H+(Cy)>A (A)=25H SWAP A ;累加器A内容上下四位互换 (A)=52H PUSH ACC ;累加器A内容压栈 POP DPH ;堆栈内容弹出到DPH (DPH)=52H PUSH ACC ;累加器A内容压栈 POP B ;堆栈内容弹出到B (B)=52H MOV A,R2 ;(R2)>A (A)=0

14、0H MOV DPL,A ;(A)>DPL (DPL)=00H MOV A,B ; (B)>A (A)=52H PUSH ACC ;累加器A内容压栈 (SP)=51H END(A)= 52H (R2)= 00H (20H)= 25H (DPTR)= 5200H (SP)= 51H 7、 ORG 0 LJMP START ;跳转到PC0030H处 ORG 30HSTART: MOV DPTR,#2100H ;#2100H>DPTR (DPTR)=2100H CLR A ;0>A (A)=00H MOV R1,#30H ;#30H>R1 (R1)=30H SETB C

15、 ;1>Cy (Cy)=1 ADDC A,R1 ;(A)+(R1)+Cy>A (A)=31H MOV R1,A ;(A)>(R1) (30H)=31H PUSH ACC ;累加器A的内容压栈 POP DPL ;堆栈内容弹出到DPL (DPL)=31H RR A ;累加器A的内容循环右移 (A)=98H MOV R0,A ;(A)>R0 (R0)=98H ORL A,#24H ;(A) or 24H>A (A)=0BCH MOV P1,A ;(A)>P1 (P1)=0BCH SWAP A ;累加器A的内容上下四位交换 (A)=0CBH MOV DPH,A ;(

16、A)>DPH (DPH)=0CBH MOV B,#02H ;#02H>B (B)=02H ADD A,B ;(A)+(B)>A (A)=0CDH CLR ACC.3 ;0>ACC.3 (A)=0C5H SWAP A ;累加器A的内容上下四位交换 (A)=5CH END(A)= 5CH (R0)= 98H (DPTR)= 0CB31H (P1)= 0BCH (30H)= 31H 8、 ORG 0 LJMP START ;跳转到PC0030H处 ORG 30H START: MOV SP,#50H ;#50H>SP (SP)=50H MOV R3,#10H ;#10H

17、>R3 (R3)=10H CLR A ;累加器A内容清零 (A)=00H MOV R0,#20H ;#20H>R0 (R0)=20H LOOP: MOV R0,A ;(A)>(R0) (20H)=00H INC R0 ;(R0)+1>R0 (20H)=01H DJNZ R3,LOOP ;(R3)-1>R3 假设R3不等于零那么跳转到LOOP处 SETB 00H ;1>位地址00H位 (20H.0)=1 (20H)=01H SETB C ;1>Cy (Cy)=1 SUBB A,#00H ;(A)-00H-Cy>A (A)=0FFH MOV DPL,

18、A ;(A)>DPL (DPL)=0FFH PUSH ACC ;累加器A的内容压栈 MOV A,R3 ;(R3)>A (A)=00H MOV DPH,A ;(A)>DPH (DPH)=00H POP ACC ;堆栈内容弹出到A (A)=0FFH MOVX DPTR,A ;(A)>(DPTR) (00FFH)=0FFH ANL A,#55H ;(A) and 55H>A (A)=55H PUSH ACC ;累加器A的内容压栈 (SP)=51H CLR A ;累加器A内容清零 (A)=00H END(A)= 00H (R3)= 00H (20H)= 01H (DPTR

19、)= 00FFH (SP)= 51H 9、 ORG 0 LJMP START ;跳转到PC0030H处 ORG 30HSTART: MOV R0,#30H ;#30H>R0 (R0)=30H MOV R1,#20H ; #20H>R1 (R1)=20H MOV A,R0 ;(R0)>A (A)=30H ADD A,#37H ;(A)+#36H>A (A)=67H MOV P1,A ;(A)>P1 (P1)=67H INC R0 ;(R0)+1>R0 (R0)=31H INC R1 ;(R1)+1>R0 (R1)=21H ANL A,R1 ;(A)&am

20、p;(R1)>A (A)=21H SWAP A ;累加器A的上下4位交换 (A)=12H PUSH ACC ;累加器A内容压栈 MOV P1,A ;(A)>P1 (P1)=12H SWAP A ;累加器A的上下4位交换 (A)=21H POP B ;堆栈内容出栈到B存放器 (B)=12H MOV R0,A ;(A)>R0 (R0)=21H MOV DPTR,#2200H ;#2200H>DPTR (DPTR)=2200H SETB C ;1>Cy (Cy)=1 ADDC A,B ;(A)+(B)+(Cy)>A (A)=34H MOVX DPTR,A ;(A)

21、>(DPTR) (2200H)=34H END(R0)= 21H (R1)= 21H (P1)= 12H (B)= 12H (2200H)= 34H 10、 ORG 0 LJMP START ;跳转到(PC)=0030H处 ORG 30H START: MOV SP,#50H ;#50H>SP (SP)=50HMOV R2,#20H ;#20H>R2 (R2)=20H MOV DPTR,#3000H ;#3000H>DPTR (DPTR)=3000H CLR A ;0>A (A)=0 LOOP: MOVX DPTR,A ;(A)>(DPTR) INC DPT

22、R ;(DPTR)+1>DPTR DJNZ R2,LOOP ;(R2)-1>R2 假设(R2)不等于零那么转移到LOOP处 INC DPH ;(DPH)+1>DPH (DPH)=31H (R2)=00H (DPL)=20H INC DPH ;(DPH)+1>DPH (DPH)=32H MOV 20H,#38H ;#36H>(20H) (20H)=38H SETB 01H ;位地址01H置1 20H.1=1 (20H)=3AH MOV A,20H ;(20H)>A (A)=3AH MOVX DPTR,A ;(A)>(DPTR) (DPTR)=3220H

23、(3220H)=3AH INC A ;(A)+1>A (A)=3BH INC A ;(A)+1>A (A)=3CH PUSH ACC ;累加器A内容压栈 XCH A,R2 ;累加器A的内容与R2内容互换 (A)=00H (R2)=3CH POP DPH ;堆栈内容弹到DPH (DPH)=3CH ADD A,#55H ;(A)+#55H>A (A)=55H PUSH ACC ;累加器A内容压栈,(SP)=51H END(A)= 55H (R2)= 3CH (20H)= 3AH (DPTR)= 3C20H (SP)= 51H 11、 ORG 0 LJMP START ;跳转到(P

24、C)=0030H处 ORG 30HSTART: MOV R0,#20H ;#20H>R0 (R0)=20H MOV A,#31H ;#31H>A (A)=31H SETB C ;(Cy)=1 ADDC A,R0 ;(A)+(R0)+Cy>A (A)=52H MOV R0,A ;(A)>(R0) (20H)=52H SWAP A ;累加器A上下4位交换 (A)=25H DEC A ;(A)-1>A (A)=24H MOV DPTR,#2000H ;#2000H>DPTR (DPTR)=2000H INC DPH ;(DPH)+1>DPH (DPH)=21

25、H DEC DPL ;(DPL)-1>DPL (DPL)=0FFH MOV P1,A ;(A)>P1 (P1)=24H INC A ;(A)+1>A (A)=25H MOVX DPTR,A ;(A)>(DPTR) (21FFH)=25H XCH A,R0 ; (A)óR0 (A)=20H (R0)=25H RL A ;累加器A内容循环左移 (A)=40H PUSH ACC ;累加器A的内容入栈 RL A ;累加器A内容循环左移 (A)=80H POP ACC ;堆栈内容弹出到累加器A (A)=40H END(A)= 40H (R0)= 25H (DPTR)=

26、21FFH (P1)= 24H (20H)= 52H 12、 ORG 0 LJMP START ;跳转到(PC)=0030H处 ORG 30H START: MOV SP,#50H ;#50H>SP (SP)=50H MOV DPTR,#2000H ;#3000H>DPTR (DPTR)=2000H MOV 20H,#06H ;#06H>20H (20H)=06H MOV R0,#20H ;#20H>R0 (R0)=20H MOV A,#35H ;#35H>A (A)=35H MOV R2,#10H ;#10H>R2 (R2)=10H SETB 00H ;置

27、位20H.0 (20H.0)=1 (20H)=07H SETB C ;置位Cy (Cy)=1 ADDC A,R0 ;(A)+(R0)+Cy>A (A)=3DH INC R0 ;(R0)+1>R0 (R0)=21H MOV R0,A ;(A)>(R0) (21H)=3DHLOOP: DJNZ R2, LOOP ;(R2)-1>R2 假设R2内容不等于零那么转移 SWAP A ;累加器A内容的上下4位交换 (A)=0D3H PUSH ACC ;累加器A内容入栈 INC DPH ;(DPH)+1>DPH (DPH)=21H MOVX DPTR,A ;(A)>(DP

28、TR) (2100H)=0D3H POP B ;堆栈内容弹出到B (B)=0D3H RR A ;累加器A内容循环右移 (A)=0E9H ADD A,B ;(A)+(B)>A (A)=0BCH MOV P1,A ;(A)>P1 (P1)=0BCH END(21H)= 3DH (R2)= 00H (A)= 0BCH (B)= 0D3H (2100H)= 0D3H 13、 ORG 0 LJMP START ;跳转到PC0030H处 ORG 30H START: MOV DPTR,#2000H ;#2000H>DPTR (DPTR)=2000H MOV A,#36H ;#36H>

29、;A (A)=36H MOV R0,#30H ;#30H>R0 (R0)=30H SETB C ;1>Cy (Cy)=1 MOV R0,A ;(A)>(R0) (30H)=36H RLC A ;累加器A的内容带进位循环左移 (A)=6DH XCH A,R0 ;累加器A的内容与20H单元的内容互换 (A)=36H (30H)=6DH PUSH ACC ;累加器A的内容入栈 POP DPL ;堆栈内容弹出到DPL (DPL)=36H MOVX DPTR,A ;(A)>(DPTR) (2036H)=36H DEC A ;(A)1>A (A)=35H PUSH DPH ;

30、DPH内容压栈 POP B ;堆栈内容弹出到B (B)=20H ADD A,B ;(A)+(B)>A (A)=55H MOV P1,A ;(A)>P1 (P1)=55H CLR A ;累加器A内容清零 ADD A,B ;(A)+(B)>A (A)=20H END(P1)= 55H (B)= 20H (30H)= 6DH (DPTR)= 2036H (R0)= 30H 14、 ORG 0 LJMP START ;跳转到PC0030H处 ORG 30H START: MOV SP,#60H ;#60H>SP (SP)=60H MOV R0,#20H ;#20H>R0

31、(R0)=20H MOV R2,#10H ;#10H>R2 (R2)=10H MOV A,#24H ;#24H>A (A)=24H LOOP: MOV R0,A ;(A)>(R0) INC R0 ;(R0)+1>R0 DJNZ R2,LOOP ;(R2)-1>R2 假设R2内容不等于0那么跳转到LOOP处 SETB 01H ;1>位地址为01H的位 (20H.1)=1 (20H)=26H SETB C ;1>Cy (Cy)=1 ADDC A,20H ;(A)+(20H)+(Cy)>A (A)=4BH SWAP A ;累加器A内容上下四位互换 (A

32、)=0B4H PUSH ACC ;累加器A内容压栈 POP DPH ;堆栈内容弹出到DPH (DPH)=0B4H PUSH ACC ;累加器A内容压栈 POP B ;堆栈内容弹出到B (B)=0B4H MOV A,R2 ;(R2)>A (A)=00H MOV DPL,A ;(A)>DPL (DPL)=00H ADD A,B ;(A)+(B)>A (A)=0B4H PUSH ACC ;累加器A内容压栈 (SP)=61H END(A)= 0B4H (R0)= 30H (20H)= 26H (DPTR)= 0B400H (SP)= 61H 15、 ORG 0 LJMP START ;跳转到PC0030H处 ORG 30HSTART: MOV DPTR,#1100H ;#1100H>DPTR (DPTR)=1100H CLR A ;0>A (A)=00H MOV R1,#20H ;#20H>R1 (R1)=20H SETB C ;1>Cy (Cy)=1 ADDC A,R1 ;(A)+(R1)+Cy>A (A)=21H MOV R1,A ;(A)>(R1) (20H)=21H INC A ;(A)+1>A (A)=22H INC A

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论