十字路口交通灯的变化规律要求:(1)南北路口的绿灯、东西路口的红灯同时亮30秒左右。(2)南北路口的黄灯闪烁若干次,同时东西路口的红灯继续亮。(3)南北路口的红灯、东西路口的绿灯同时亮30秒左右。(4)南北路口的红灯继续亮、同时东西路口的黄灯亮闪烁若干次。(5)转(1)重复。通过连接的七段数码管动态显示绿灯剩余时间本次试验环境为tcp-usb实验板,清华大学出的板子。下面是我的实现的全部代码,附带注释。代码遵循gpl协议,欢迎修改。*************************************************************;data:20:132009-9-8;author:muzi;@zzu.modelsmall.stack.dataleddb3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh;段码geweiword8;存放要显示的个位和十位shiweiword8counterbyte10intoffword?;保存原中断服务程序的偏移地址intsegword?;....................段基地址.code.startupmovdx,28bh;初始化8255,设置a口,c口输出moval,80houtdx,al;初始化8253,输出1HZ的方波,作为中断输入moval,00110110b;初始化计数器0,工作方式3,计数初值为1000movdx,283houtdx,almovax,1000movdx,280houtdx,almoval,ahoutdx,almoval,01110110b;初始化计数器1,工作方式3,计数初值为1000movdx,283houtdx,almovax,1000movdx,281houtdx,almoval,ahoutdx,al;设置中断,中断号0bhmovax,350bh;设置系统0b号中断int21hmovintoff,bxmovintseg,esclipushdsmovdx,offsetnew0bhmovax,segnew0bhmovds,axmovax,250bhint21hpopdsinal,21h;读取imrandal,0f7h;允许irq3,其他不变out21h,al;设置imrstigo:movcounter,30;南北绿灯倒计时秒数callgreenn;南北绿灯,东西黄灯,30sgo2:callxianshimoval,counteraddal,2cmpal,1jbgo1jmpgo2go1:cli;关中断callyellown;南北黄灯闪sti;开中断movcounter,30callgreenego3:callxianshimoval,counteraddal,2cmpal,1jbgo4jmpgo3go4:clicallyellowestijmpgo.exitdelay0proc;延时子程序,控制数码管显示时间(亮度)timer=2pushbxpushcxmovbx,timerdelay1:xorcx,cxdelay2:loopdelay2decbxjnzdelay1popcxpopbxretdelay0endpcloseledproc;关闭数码管显示子程序moval,00000000b;关闭数码管pc0=0movdx,28bhoutdx,almoval,00000010b;关闭数码管pc1=0movdx,28bhoutdx,alretcloseledendpnew0bhprocpushbxpushaxpushcxpushsipushdsmovax,@datamovds,axmovbl,10moval,countermovah,0divblmovbx,axmovah,0movshiwei,axmovbl,bhmovbh,0movgewei,bxdeccountermoval,20h;发送eoi命令out20h,alpopdspopsipopcxpopaxpopbxiretnew0bhendpxianshiproccallcloseledmovax,shiweimovsi,offsetled;置led数码表偏移地址为SIaddsi,axmoval,byteptr[si];求出对应的led数码movdx,288h;自8255A的口输出outdx,almoval,00000011b;使相应的数码管亮,显示十位pc1=1movdx,28bhoutdx,alcalldelay0callcloseledmovax,geweimovsi,offsetled;置led数码表偏移地址为SIaddsi,axmoval,byteptr[si];求出对应的led数码movdx,288h;自8255A的口输出outdx,almoval,00000001b;使相应的数码管亮,显示个位pc0=1movdx,28bhoutdx,alcalldelay0retxianshiendpgreennproc;南北绿灯子程序movdx,28bhmoval,10000000boutdx,almovdx,28ahmoval,00110000boutdx,alretgreennendpgreeneproc;东西绿灯子程序movdx,28bhmoval,10000000boutdx,almovdx,28ahmoval,10000100boutdx,alretgreeneendpyellownproc;南北黄灯闪子程序movdx,28bhmoval,10000000boutdx,almovdx,28ahtime1=3movcx,time1abb:moval,01010000boutdx,alcalldelaymoval,00010000boutdx,alcalldelayloopabbretyellownendpyelloweproc;东西黄灯闪子程序movdx,28bhmoval,10000000boutdx,almovdx,28ahtime1=3movcx,time1abc:moval,10001000boutdx,alcalldelaymoval,10000000boutdx,alcalldelayloopabcretyelloweendpdelayproc;延时子程序,控制黄灯闪烁timer=250pushbxpushcxmovbx,timerdelay11:xorcx,cxdelay22:loopdelay22decbxjnzdelay11popcxpopbxretdelayendpend