1、广工自动化单片机课程设计 自动化 学院 网络工程 专业 班 学号 姓名 1. 程序一: 在显示器上显示任意四位十六进制数: 56AFORG 0000HLJMP MAINORG 1000HMAIN:MOV52H,#02HMOV53H,#03HMOV51H,#01HMOV50H,#00HMOV R5,#53HKEYSUB:MOVA,#0DHMOVDPTR,#7F00HMOVXDPTR,ABEGIN:ACALLDISAJMPBEGINDIS:PUSHACCPUSH00HPUSH03HMOVR0,#50HMOVR3,#7FHMOVA,R3AGAIN:MOVDPTR,#7F03HMOVXDPTR,AMO
2、VA,R0MOVDPTR,#DDEGMOVA,A+DPTRMOVDPTR,#7F01HMOVXDPTR,AACALLDLIMSINCR0MOVA,R3JNBACC.3,OUTRRAMOVR3,AAJMPAGAINOUT:POP03HPOP00HPOPACCRETDDEG:DB79H,7CH,07H,5BH,6FH,7FH,77H,39HA1:MOVA,R3MOVDPTR,#7F01HMOVXDPTR,AMOVDPTR,#1000HMOVA,R2MOVCA,A+DPTRMOVDPTR,#7F02HMOVXDPTR,ACALLDLIMSINCR2MOVA,R3RLAMOVR3,AJNBACC.4,
3、BEGINJMPA1DLIMS:MOVR7,#05HDL0:MOVR6,#0FFHDL1:DJNZR6,DL1DJNZR7,DL0RETEND2.程序二: 将8个键按实验室要求定义键值, 按任意键在显示器上显示对应键值, 要求显示值能左移; 98ACEB72ORG0000HLJMPMAINORG1000HMAIN:MOV 52H,#00HMOV 53H,#00HMOV 51H,#00HMOV 50H,#00HMOV R5,#53HKEYSUB:MOV A,#0DHMOVDPTR,#7F00HMOVX DPTR,ABEGIN:ACALL DISACALL CLEARACALL CCSCANJNZ
4、 INK1AJMPBEGININK1:ACALL DISACALL DLIMSACALL DLIMSACALL CLEARACALL CCSCANJNZ INK2AJMP BEGININK2:MOV R2,#07fHMOV R4,#00HCOLUM:MOV DPTR,#7F03HMOV A,R2MOVX DPTR,AINC DPTRINC DPTRMOVX A,DPTRJB ACC.2,LONEMOV A,#00HAJMP KCODELONE:JBACC.6,NEXTMOV A,#04HKCODE:ADD A,R4CJNEA,#00H,XYGMOVA,#09HAJMPXYG7XYG:CJNEA
5、,#01H,XYG1MOVA,#08HAJMPXYG7XYG1:CJNEA,#02H,XYG2MOVA,#0AHAJMPXYG7XYG2:CJNEA,#03H,XYG3MOVA,#0CHAJMPXYG7XYG3:CJNEA,#04H,XYG4MOVA,#0EHAJMPXYG7XYG4:CJNEA,#05H,XYG5MOVA,#0BHAJMPXYG7XYG5:CJNEA,#06H,XYG6MOVA,#07HAJMPXYG7XYG6:CJNEA,#07H,XYG7MOVA,#02HAJMPXYG7XYG7:ACALLPUTBUFPUSHACCKON:ACALL DISACALL CLEARACAL
6、L CCSCANJNZ KONPOP ACCNEXT:INC R4MOV A,R2JNB ACC.3,KEERRR AMOV R2,AAJMP COLUMKERR:AJMP BEGINCCSCAN:MOV DPTR,#7F03HMOV A,#00HMOV DPTR,AINC DPTRINC DPTRMOVX A ,DPTRCPL AANL A,#44HRETCLEAR:MOV DPTR,#7F03HMOV A,#00HMOVX DPTR,ARETDIS:PUSH ACCPUSH 00HPUSH 03HMOV R0,#50HMOV R3,#0F7HMOV A,R3AGAIN:MOV DPTR,#
7、7F03HMOVX DPTR,AMOV A,R0MOV DPTR,#DDEGMOVC A,A+DPTRMOV DPTR,#7F01HMOVX DPTR,AACALL DLIMSINC R0MOV A,R3JNBACC.0,OUTRL AMOV R3,AAJMP AGAINOUT:POP 03HPOP 00HPOP ACCRETDDEG:DB0FCH,60H,0DAH,0F2HDB66H,0B6H,0BEH,0E0HDB0FEH,0F6H,0EEH,3EHDB9CH,7AH,9EH,8EHDLIMS:MOV R7,#01HDL0:MOV R6,#0FFHDL1:DJNZ R6,DL1DJNZ R
8、7,DL0RETPUTBUF:PUSH 00HPUSHACCMOV53H,52HMOV52H,51HMOV51H,50HPOPACCMOV50H,AGOBACK:POP 00HRETEND2. 程序三: 程序实现以下要求a) 定义键盘按键b) 可进行三位16进制除法运算c) 可进行两位10进制乘法运算 ORG0000HLJMPMAINORG1000HMAIN:MOV53H,#00HMOV52H,#00HMOV51H,#00HMOV50H,#00HMOV60H,#00HMOV61H,#00HMOV62H,#00HMOV63H,#00HMOV64H,#00HMOV65H,#00HMOV66H,#0
9、0HMOV67H,#00HMOV68H,#0CCHKEYSUB:MOV A,#0DHMOVDPTR,#7F00HMOVX DPTR,ABEGIN:ACALL DISACALL CLEARACALL CCSCANJNZ INK1AJMPBEGININK1:ACALL DISACALL DLIMSACALL DLIMSACALL CLEARACALL CCSCANJNZ INK2AJMP BEGININK2:MOV R2,#07fHMOV R4,#00HCOLUM:MOV DPTR,#7F03HMOV A,R2MOVX DPTR,AINC DPTRINC DPTRMOVX A,DPTRJB ACC
10、.2,LONEMOV A,#00HAJMP KCODELONE:JBACC.6,NEXTMOV A,#04HKCODE:ADD A,R4CJNEA,#00H,XYGMOVA,#09HAJMPXYG7XYG:CJNEA,#01H,XYG1MOVA,#08HAJMPXYG7XYG1:CJNEA,#02H,XYG2MOVA,#0AHAJMPXYG7XYG2:CJNEA,#03H,XYG3MOVA,#0CHAJMPXYG7XYG3:CJNEA,#04H,XYG4MOVA,#0EHAJMPXYG7XYG4:CJNEA,#05H,XYG5MOVA,#0BHAJMPXYG7XYG5:CJNEA,#06H,X
11、YG6MOVA,#07HAJMPXYG7XYG6:CJNEA,#07H,XYG7MOVA,#02HAJMPXYG7XYG7:ACALLPUTBUFPUSHACCKON:ACALL DISACALL CLEARACALL CCSCANJNZ KONPOP ACCNEXT:INC R4MOV A,R2JNB ACC.3,KEERRR AMOV R2,AAJMP COLUMKERR:AJMP BEGINCCSCAN:MOV DPTR,#7F03HMOV A,#00HMOV DPTR,AINC DPTRINC DPTRMOVX A ,DPTRCPL AANL A,#44HRETCLEAR:MOV DP
12、TR,#7F03HMOV A,#00HMOVX DPTR,ARETDIS:PUSH ACCPUSH 00HPUSH 03HMOV R0,#50HMOV R3,#0F7HMOV A,R3AGAIN:MOV DPTR,#7F03HMOVX DPTR,AMOV A,R0MOV DPTR,#DDEGMOVC A,A+DPTRMOV DPTR,#7F01HMOVX DPTR,AACALL DLIMSINC R0MOV A,R3JNBACC.0,OUTRL AMOV R3,AAJMP AGAINOUT:POP 03HPOP 00HPOP ACCRETDDEG: DB 11H,12H,0CH,66HDB 1
13、0H,09H,04H,08HSZDEG:DB 0FCH,60H,0DAH,0F2HDB 66H,0B6H,0BEH,0E0HDB 0FEH,0F6H,0EEH,3EHDB 9CH,7AH,9EH,8EHDB 0CCH,0DDH,0EEHPUTBUF:PUSH 00HPUSHACCMOVA,62HMOV63H,AMOVA,61HMOV62H,AMOVA,60HMOV61H,APOPACCPUSHDPHPUSHDPLMOVR5,AMOVDPTR,#DDEGMOVCA,A+DPTRMOV60H,AMOVA,R5POPDPLPOPDPHGOBACK:POP 00HJISUAN:CJNEA,#02H,C
14、HUHAOACALLFUHAOAJMPJSENDCHUHAO:CJNEA,#01H,DENGYUHAOACALLFUHAOAJMPJSENDDENGYUHAO:CJNE A,#03H,SHUZIACALLDENGYUAJMPJSENDSHUZI:ACALLPUTBUFJSEND:RETFUHAO:PUSHACCPUSHDPHPUSHDPLMOVDPTR,#DDEGMOVCA,A+DPTRMOVDPTR,#SEDEGMOVCA,A+DPTRMOV68H,AMOVA,60HMOV64H,AMOVA,61HMOV65H,AMOVA,62HMOV66H,AMOVA,63HMOV67H,AMOV60H,
15、#00HMOV61H,#00HMOV62H,#00HMOV63H,#00HPOPDPLPOPDPHPOPACCRETDENGYU:PUSHACCMOVA,61HANLA,#0FHRLARLARLARLAMOVR5,AMOVA,60HANLA,#0FHORLA,R5MOV50H,AMOVA,63HANLA,#0FHRLARLARLARLAMOVR5,AMOVA,62HANLA,#0FHORLA,R5MOV51H,AMOVA,65HANLA,#0FHRLARLARLARLAMOVR5,AMOVA,64HANLA,#0FHORLA,R5MOV52H,AMOVA,67HANLA,#0FHRLARLAR
16、LARLAMOVR5,AMOVA,66HANLA,#0FHORLA,R5MOV53H,AMOVA,68HCJNEA,#0DDH,CHENGFAAJMPJIWANCHENGFA:MOVA,50HANLA,#07HMOV69H,AMOVA,50HANLA,#10HRRAORL69H,AMOVA,50HANLA,#60HRRAMOV70H,AMOVA,51HANLA,#03HSWAPARLARLAORL70H,AMOVA,51HANLA,#04HRRARRAMOV71H,AMOVA,51HANLA,#70HRRARRARRAORL71H,AMOVA,#00HORLA,71HMOV51H,AMOVA,
17、70HORLA,69HMOV50H,AMOVA,52HANLA,#07HMOV69H,AMOVA,52HANLA,#10HRRAORL69H,AMOVA,52HANLA,#60HRRAMOV70H,AMOVA,53HANLA,#03HSWAP ARLARLAORL70H,AMOVA,53HANLA,#04HRRARRAMOV71H,AMOVA,53HANLA,#70HRRARRARRAORL71H,AMOVA,#00HORLA,71HMOV53H,AMOVA,70HORLA,69HMOV52H,ADBMUL:MOVA,52HMOVB,50HMULABXCHA,50HMOV74H,BMOVB,5
18、3HMULABADDA,74HMOV75H,ACLRAADDCA,BMOV74H,AMOVA,51HMOVB,52HMULABADDA,75HXCHA,51HXCHA,BADDCA,74HMOV74H,AMOV73H,#00HPUSHACCMOVA,73HRLCAMOV73H,APOPACCMOVA,53HMULABADDA,74HMOV74H,ACLRAMOVACC.0,CPUSHACCMOVA,73HMOVC,ACC.0POPACCADDCA,BMOV75H,AMOV53H,51HMOV52H,50HCOVER:MOVA,52HANLA,#07HMOV60H,AMOVA,52HRRARRA
19、RRAANLA,#07HMOV61H,AMOVA,52HRRA RRARRARRARRARRAANLA,#03HMOV62H,AMOVA,53HJNBACC.0,BUMOVA,62HADDA,#04HMOV62H,ABU:MOVA,53HRRAANLA,#07HMOV63H,AAJMPQKJIWAN:MOVA,50HANLA,#0FHMOV60H,AMOVA,50HANLA,#0F0HRRARRARRARRAMOV61H,AMOVA,51HANLA,#0FHMOV62H,AMOVA,51HANLA,#0F0HRRARRARRARRAMOV63H,AQK:MOV50H,#00HMOV51H,#0
20、0HMOV52H,#00HMOV53H,#00HMOV64H,#00HMOV65H,#00HMOV66H,#00HMOV67H,#00HMOV68H,#0CCHPOPACCRETDL1MS:MOV R7,#05HDL0:MOV R6,#0FFHDL1:DJNZ R6,DL1DJNZ R7,DL0RETRETEND心得体会: 这次的课程设计主要是对单片机编程知识的一次综合运用,也是由理论结合实践的第一步,为我以后的学习奠定了良好的基础。经过这次课程设计, 我对单片机系统有了更加清楚地认识, 知道了所学知识的重要性, 对设计的过程与步骤以及应注意的细节都有了更为深刻的理解和领会。设计中遇到了许多平时没有遇到的问题, 可是, 在老师的精心指点,以及在同学的帮助下, 基本上得到了解决。