51单片机常见汇编程序实验代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

11.将片外8000H-80FFH单元写入数据AB·····················································12.将片内RAM20H单元中数据在数码管上显示出来······································13.将片内ARM30H-40H单元清零·······24.将六位数显示在数码管上················25.8255并口芯片的应用:交通灯控制系统的设计············································36.将交通灯点亮·······························37.AD转换实验································48.DA转换实验································59.定时器的应用·······························510.开关控制LED的亮灭及速度·········611.计数器实验································612.串并转换实验·····························713.直流电机速度检测·······················714.8255PB外接8个开关,编程将开关状态显示在数码管上(串并转换动态扫描方式)···············································815.P3.4接开关K,编程将开关拨动次数,通过串并转换的方式进行显示·············916.比较片内RAM30H、31H两个单元值的大小,将较大的数显示在数码管上··1017.单片机P1口接8个开关,编程将开关状态显示在数码管上(串并转换动态扫描方式)··········································1018.将片内50H单元的值显示在数码管上1119.开关K1接P1.0,K2接P1.1,编程实现当按下K1时在数码管上显示50H单元的值,按下K2在数码管上显示51H单元的值·············································121.将片外8000H-80FFH单元写入数据ABORG0000H;程序从0000H开始执行AJMPMAIN;跳转到主程序ORG0030H;以免覆盖中断地址MAIN:MOVSP,#60H;避免堆栈和工作寄存器区冲突MOVDPTR,#8000HMOVR0,#0LOOP:MOVA,#0ABHMOVX@DPTR,AINCDPTRINCR0CJNER0,#0,LOOP;判断AJMP$;等待END;调试-视图-M存储器(输入地址X:8000H)2.将片内RAM20H单元中数据在数码管上显示出来ORG0000H;程序从0000H开始执行AJMPMAIN;跳转到主程序ORG0030H;以免覆盖中断地址MAIN:MOVSP,#60H;避免堆栈和工作寄存器区冲突MOVDPTR,#0E100H;指向命令口地址MOVA,#03H;PA、PB口输出MOVX@DPTR,A;所有并口显示程序先进行8155初始化MOV20H,#34HMOVA,20HACALLCHAILOOP:MOVR0,#10H;第一个显示数的地址送R0MOVR1,#2;显示2个数MOVR2,#1;从倒数第一个数码管开始显示ACALLDISPLAYLJMPLOOP;判断CHAI:MOVB,#10HDIVABMOV10H,BMOV11H,ARETDISPLAY:MOVA,@R0MOV0FH,#8ACALLP164ACALLPBITACALLDELAYMOVA,#0MOVX@DPTR,AINCR0DJNZR1,DISPLAY2RETP164:MOVDPTR,#TABMOVCA,@A+DPTRP164_1:RRCAMOVR3,AMOVACC.0,CANLA,#0FDHMOVDPTR,#0E102HMOVX@DPTR,AORLA,#0FEHMOVX@DPTR,AMOVA,R3DJNZ0FH,P164_1MOV0FH,#8RETPBIT:MOVDPTR,#0E101HMOVA,R2MOVX@DPTR,ARLAMOVR2,ARETDELAY:MOVR6,#4DEL:MOVR7,#250DJNZR7,$DJNZR6,DELRETTAB:DB0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0HDB0FEH,0F6H,0EEH,3EH,9CH,7AH,9EH,8EHEND3.将片内ARM30H-40H单元清零ORG0000H;程序从0000H开始执行AJMPMAIN;跳转到主程序ORG0030H;以免覆盖中断地址MAIN:MOVSP,#60H;避免堆栈和工作寄存器区冲突MOVR0,#30HMOVA,#0LOOP:MOV@R0,AINCR0CJNER0,#41H,LOOP;判断AJMP$;等待END;地址D:30H4.将六位数显示在数码管上ORG0000H;程序从0000H开始执行AJMPMAIN;跳转到主程序ORG0030H;以免覆盖中断地址MAIN:MOVSP,#60H;避免堆栈和工作寄存器区冲突MOVDPTR,#0E100H;指向命令口地址MOVA,#03H;PA、PB口输出MOVX@DPTR,A;所有并口显示程序先进行8155初始化LOOP:MOVR0,#10H;第一个显示数的地址送R0MOV10H,#0HMOV11H,#3HMOV12H,#1HMOV13H,#2HMOV14H,#1HMOV15H,#1HMOVR1,#6;显示6个数MOVR2,#1;从倒数第一个数码管开始显示ACALLDISPLAYLJMPLOOPDISPLAY:MOVA,@R0MOV0FH,#8ACALLP164ACALLPBITACALLDELAYMOVA,#0MOVX@DPTR,AINCR0DJNZR1,DISPLAYRETP164:MOVDPTR,#TABMOVCA,@A+DPTRP164_1:RRCAMOVR3,AMOVACC.0,C3ANLA,#0FDHMOVDPTR,#0E102HMOVX@DPTR,AORLA,#0FEHMOVX@DPTR,AMOVA,R3DJNZ0FH,P164_1MOV0FH,#8RETPBIT:MOVDPTR,#0E101HMOVA,R2MOVX@DPTR,ARLAMOVR2,ARETDELAY:MOVR6,#4DEL:MOVR7,#250DJNZR7,$DJNZR6,DELRETTAB:DB0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0HDB0FEH,0F6H,0EEH,3EH,9CH,7AH,9EH,8EHEND5.8255并口芯片的应用:交通灯控制系统的设计ORG0000HAJMPSTARTORG0030HSTART:MOVDPTR,#0AC03HMOVA,#80HMOVX@DPTR,A//8155初始化(所有并口显示中都要先8155初始化)MOVR5,#0F0HACALLDENGMOVR1,#20ACALLDELAYMOVR0,#1LOOP01:MOVR5,#5AHACALLDENGMOVR1,#100ACALLDELAYDJNZR0,LOOP01MOVR0,#3//LED_2闪烁次数LOOP02:MOVR5,#0FAHACALLDENGMOVR1,#10ACALLDELAYMOVR5,#50HACALLDENGMOVR1,#10ACALLDELAYDJNZR0,LOOP02MOVR5,#0A5HACALLDENGMOVR1,#100ACALLDELAYMOVR0,#3LOOP03:MOVR5,#0F5HACALLDENGMOVR1,#10ACALLDELAYMOVR5,#0A0HACALLDENGMOVR1,#10ACALLDELAYDJNZR0,LOOP03AJMPLOOP01DENG:MOVDPTR,#0AC00H//8155PA口输出MOVA,R5MOVX@DPTR,A//8155PA口送出显示参数RET//100ms延时子程序DELAY:MOVR7,#200DEL:MOVR6,#229DJNZR6,$DJNZR7,DELDJNZR1,DELAYRETEND6.将交通灯点亮ORG0000HAJMPSTARTORG0030HSTART:MOVDPTR,#0AC03H4MOVA,#80HMOVX@DPTR,AMOVDPTR,#0AC00HMOVA,#05AHMOVX@DPTR,AAJMP$END7.AD转换实验ORG0000AJMPSTARTORG000BHAJMPINT_0ORG0030HSTART:MOVSP,#60HMOVTMOD,#01HMOVTH0,#4BHMOVTL0,#0FDHMOVR4,#2SETBEASETBET0SETBTR0MOVDPTR,#0E100HMOVA,#3MOVX@DPTR,AMOV22H,#9MOV23H,#0MOV24H,#8MOV25H,#0LOOP:MOVR0,#20HMOVR1,#6MOVR2,#1ACALLDISPLAYSJMPLOOPINT_0:MOVTH0,#4BHMOVTL0,#0FDHDJNZR4,EXITPUSHACCPUSHDPHPUSHDPLMOVDPTR,#0A000HMOVXA,@DPTRMOVB,#10HDIVABMOV21H,AMOV20H,BMOVX@DPTR,AMOVR4,#2POPDPLPOPDPHPOPACCEXIT:RETIDISPLAY:MOVA,@R0MOV0FH,#8ACALLP164ACALLPBITACALLDELAYMOVA,#0MOVX@DPTR,AINCR0DJNZR1,DISPLAYRETP164:MOVDPTR,#TABMOVCA,@A+DPTRP164_1:RRCAMOVR3,AMOVACC.0,CANLA,#0FDHMOVDPTR,#0E102HMOVX@DPTR,AORLA,#0FEHMOVX@DPTR,AMOVA,R3DJNZ0FH,P164_1MOV0FH,#8RETPBIT:MOVDPTR,#0E101HMOVA,R2MOVX@DPTR,ARLAMOVR2,ARETDELAY:MOVR6,#4DEL:MOVR7,#250DJNZR7,$DJNZR6,DELRETTAB:DB50FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0HDB0FEH,0F6H,0EEH,3EH,9CH,7AH,9EH,8EHEND8.DA转换实验ORG0000SJMPSTARTORG0030HSTART:MOVSP,#60HMOVA,#0LOOP1:MOVDPTR,#0B000HMOVX@DPTR,AACALLXSACALLDELAYINCACJNEA,#0FFH,LOOP1LOOP2:MOVDPTR,#0B000HMOVX@DPTR,AACALLXSACALLDELAYDECACJNEA,#0,LOOP2SJMPLOOP1XS:PUSHACCMOVDPTR,#TABMOVB,#51DIVABMOVR1,AXCHA,BMOVB,#5DIVABMOVCA,@A+DPTRMOVR4,#8ACALLS164MOVA,R1MOVCA,@A+DPTRMOVR4,#8ACALLS164MOVA,#0CLRCMOVR4,#16ACALLS164POPACCRETS164:RRCAMOVP1.0,CCLRP1.1SETBP1.1DJNZR4,S164RETDELAY:MOVR7,#200DEl:MOVR6,#229DJNZR6,$DJNZR7,DELRETTAB:DB0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0HDB0FEH,0F6H,0EEH,3EH,9CH,7AH,9EH,8EHEND9.定时器的应

1 / 13
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功