资源描述:
《交通灯汇编程序设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、;*************定义数据段***********************************************datasegmenttitle1db'Traffic-System'dengdb'###'sing1db'South-North'sing2db'East-West'sing3db'Redtime(scend):'timedb'Time:'sing4db'Yellowtime(scend):'buffdb4;键盘缓冲区buff1db3dup(?);工作计数区buff2db3dup(?);数据保存区yellowdb?;黄灯时
2、间modedb'Mode:auto(Y/N)?:'ansdb?ting3db'Redtime(scend):030'ting4db'Yellowtime(scend):5';************************主程序段**********************************************dataendscodesegmentassumecs:code,ds:data,es:datastart:movax,datamovds,axmoves,axcalltitle2;初始化标题q0:callmode1;模式选择自动或手动c
3、allscanfcallatuo;默认设置参数启动leasi,anscmpbyteptr[si],'y'jzq1cmpbyteptr[si],'n'jnzq0callask1;设置红灯时间callscanf0callask2;设置黄灯时间callscanf1q1:callinit1;初始化灯光callinit2leasi,buff;复制数据buff-buff1,保存显示时间incsiincsileadi,buff1cldmovcx,3REPmovsbleasi,buff1;复制数据buff1-buff2,保存显示时间leadi,buff2cldmovcx
4、,3REPmovsb;********************子程序设计**************************************;*******状态一:南北方向红灯,东西方向绿灯*****************************start1:leasi,buff2;复制数据buff2-buff1,保存显示时间leadi,buff1cldmovcx,3REPmovsbleadi,buff1a0:cmpbyteptr[di+2],30h;数据处理部分jaa1addbyteptr[di+2],10subbyteptr[di+1],1
5、a1:subbyteptr[di+2],1cmpbyteptr[di+1],30hjnca2addbyteptr[di+1],10subbyteptr[di],1a2:cmpbyteptr[di],30hjnca3jmpstart2;换灯a3:callnrcallwrite0callwrite1leasi,yellowmoval,[si]cmpbyteptr[di+2],al;最后五秒绿灯变黄灯jnaa4jmpa8a4:cmpbyteptr[di+1],30hjnaa5jmpa8a5:cmpbyteptr[di],30hjaa8calleyjmpa9a8
6、:callega9:calldelay;延时一秒左右jmpa0;********状态二:南北方向绿灯,东西方向红灯****************************start2:leasi,buff2;复制数据buff2-buff1,保存显示时间leadi,buff1cldmovcx,3REPmovsbleadi,buff1b0:cmpbyteptr[di+2],30h;数据处理部分jab1addbyteptr[di+2],10subbyteptr[di+1],1b1:subbyteptr[di+2],1cmpbyteptr[di+1],30hjn
7、cb2addbyteptr[di+1],10subbyteptr[di],1b2:cmpbyteptr[di],30hjncb3jmpstart1;换灯b3:callercallwrite0callwrite1leasi,yellowmoval,[si]cmpbyteptr[di+2],al;最后五秒绿灯变黄灯jnab4jmpb8b4:cmpbyteptr[di+1],30hjnab5jmpb8b5:cmpbyteptr[di],30hjab8callnyjmpb9b8:callngb9:calldelay;延时一秒左右jmpb0;******模式设置*
8、**************mode1procmovcx,16;设置时间leab