资源描述:
《硬件课程设计交通灯源代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、衣通灯源代码MY8255_AEQU1400HMY8255__BEQU1401HMY8255cEQU1402HMY8255MODEEQU1403H;8255连接端口IOYOMY8254_COUNTOEQU1440H;8254连接端口IOY2MY8254_MODEEQU1443HDATASEGMENTLEDDB3FH,06Hz5BH,4FH,66H,6DH,7DH,07H,7FHz6FH;数码管七段代码表DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AX
2、MOVDX?MY8255_MODE;8255初始化,连接端口IOYOMOVALJOOOOOOIB;A口输出接LEDZB口输出接数码管,C0~C3输入,C4~C7输出OUTDX,ALAl:MOVDX,MY8255_A;8255的A口接LED()MOVAL,01101111B;东西红,南北绿OUTDX,AL;将灯状态传送给LED显示MOVCX,30;计时30秒CALLCHULI1MOVDX,MY8255_A;从8255的A口读出灯的状态INAL,DXCMPAL,01101111BJEA2CMPALJOOlllllBJEA4CMPA
3、milllUlBJEAlCMPALJlllOOllBJEAl•**/———_____**A2:MOVDX,MY8255_A;东西红,南北黄MOVAL,01111011BOUTDX,ALMOVCX,5;计时5秒CALLCHULI2MOVDX?MY8255_A;从8255的A口读出灯的状态INAL,DXCMPAL,O11O1111BJEA2CMPALZ1OO11111BJEA4CMPAL4H11111BJEAlCMPALJlllOOllBJEAl.**/**A3:MOVDX,MY8255_A;东西绿,南北红MOVAL^OOllll
4、lBOUTDX,ALMOVCX,30;计时30秒CALLCHULI1MOVDXZMY8255_A;从8255的A口读出灯的状态INAL,DXCMPAL^llOllllBJEA2CMPAL,10011111BJEA4CMPALJlllllllBJEAlCMPA^llllOOllBJEAl・**/**A4:MOVDX,MY8255_A;东西黄,南北红MOVAL,10110111BOUTDX,ALMOVCX,5;计时5秒CALLCHULI2MOVDX,MY8255_A;从8255的A口读出灯的状态INAL,DXCMPAL,O11O1
5、111BJEA2CMPAL,1OO11111BJEA4CMPALZ11111111BJEAlCMPAL41H0011BJEAl.**/**JMPAl;循环到状态A1,即东西红,南北绿EXIT:MOVAH,4CHINT21H.**/**.**CHULI1PROCPUSHAXPUSHDXPUSHCXLOOP1:CALLINITIA「8254;判断有无键按下LOOP2:MOVAH?OBHINT21HCMPAL,0JNZEXIT则返回DOSMOVDXZMY8255CINAL,DXTESTA^OOOOlllOB键按下JZLICALLEM
6、ERGECY紧急键处理JMPL2LI:CALLDISPL2:MOVDX,MY8255_CINAL,DXTESTAL,O1HJELOOP2继续LOOPLOOPl全?若没计数完,继续POPexPOPDXPOPAXRETCHULI1ENDPCHULI2PROCPUSHAXPUSHDXPUSHCXLOOP3:CALLINITIAL_8254LOOP4:MOVAH,OBH;有键入;检测是否有紧急;有紧急键则转到;检测Is是否计完;若尢没计数完,;30s或5s计数完;判断有无键按下INT21HCMPAL,0JNZEXIT;有键入则返冋DO
7、SMOVDX,MY8255CINAL,DXTESTA^OOOOlllOB键按下JZL3CALLEMERGECY紧急键处理JMPL4L3:CALLDISPL4:MOVDX,MY8255_CINAL,DXTESTAL,O1HJELOOP4继续MOVDX?MY8255_AINAL,DXCMPALZO1111O11B北黄,转ZHUANHUAN1JZZHUANHUAN1CMPAL^lllllllBJZZHUANHUAN1CMPALZ1O11O111B北红,转ZHUANHUAN2JZZHUANHUAN2CMPALJOllllllBJZZH
8、UANHUAN2L5:LOOPLOOP3全?若没计数完,继续POPexPOPDXPOPAXRET;检测是否有紧急;有紧急键则转到;检测is是否计完;若Is没计数完,;检查灯的状态;若为东西红,南;若为东西黄,南;30s或5s计数完ZHUANHUAN1:MOVDXZMY8254