//////////////////////////////////////////////// //名称:模拟自动车库 //电路原理:P86--P87 //作者:李春起 //版本:CARLIB.ASM-V0.0 //编写时间:2010.11.01 //修订日志: INTER EQU P3.3//驶入 LEAVE EQU P3.2//驶离 IN EQU P1.6//存入 OUT EQU P1.7//取出 ORG 0000H JMP MAIN // ORG 000BH // JMP T00 ORG 0030H MAIN:MOV TMOD,#01H MOV TH0,#3CH MOV TL0,#0B0H SETB TR0 SETB EA SETB ET0 MOV 20H,#0FFH //车位状态初始化 MOV 21H,#0FFH//请求车位 LOOP://ACALL DELAY2S //CLR P2.4//初始态平板车位置 SETB P2.0 SETB P2.1 SETB P2.2 K1: JB INTER,K2//不等0转移 JNB INTER,$//等待放开 CLR P2.4//指示有车待入库 K2: JB LEAVE,K3 JNB LEAVE,$ SETB P2.4 K3: JB IN,K4 JNB IN,$ CLR P2.4 CLR P2.1//选择存入 SETB P2.0 JMP K5 K4: JB OUT,K1 JNB OUT,$ CLR P2.0 SETB P2.1 JMP K6 K5: SETB P2.2 KA1:JB OUT,KA2 JMP K1 JB P1.0,KA2 JNB P1.0,$ JNB P0.0,KA2 CLR P2.2 MOV 20H,#0FEH JMP KENT KA2:JB P1.1,KA3 JNB P1.1,$ JNB P0.1,KA3// CLR P2.2 MOV 20H,#0FDH JMP KENT KA3:JB P1.2,KA4 JNB P1.2,$ JNB P0.2,KA4 CLR P2.2 MOV 20H,#0FBH JMP KENT KA4:JB P1.3,KA5 JNB P1.3,$ JNB P0.3,KA5 CLR P2.2 MOV 20H,#0F7H JMP KENT KA5:JB P1.4,KA6 JNB P1.4,$ JNB P0.4,KA6 CLR P2.2 MOV 20H,#0EFH JMP KENT KA6:JB P1.5,KENT JNB P1.5,$ JNB P0.5,KENT CLR P2.2 MOV 20H,#0DFH KENT: JB P3.0,KA1 JNB P3.0,$ JB P2.2,KA1 ACALL DELAY2S SETB P2.4 CLR P2.5 ACALL DELAY2S MOV A,20H CJNE A,#0FEH,NA1 SETB P2.5 CLR P0.0 ACALL DELAY2S CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NA1: CJNE A,#0F7H,NA2 SETB P2.5 CLR P0.3 ACALL DELAY2S CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NA2: SETB P2.5 CLR P2.6 ACALL DELAY2S CJNE A,#0FDH,NA3 SETB P2.6 CLR P0.1 ACALL DELAY2S CLR P2.6 ACALL DELAY2S SETB P2.6 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NA3: CJNE A,#0EFH,NA4 SETB P2.6 CLR P0.4 ACALL DELAY2S CLR P2.6 ACALL DELAY2S SETB P2.6 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NA4: SETB P2.6 CLR P2.7 ACALL DELAY2S CJNE A,#0FBH,NA5 SETB P2.7 CLR P0.2 ACALL DELAY2S CLR P2.7 ACALL DELAY2S SETB P2.7 CLR P2.6 ACALL DELAY2S SETB P2.6 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NA5: CJNE A,#0DFH,NA6 SETB P2.7 CLR P0.5 ACALL DELAY2S CLR P2.7 ACALL DELAY2S SETB P2.7 CLR P2.6 ACALL DELAY2S SETB P2.6 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 NA6: JMP LOOP //============取车=========================== K6: SETB P2.2 KB1:JB IN,KB2 JMP K1 JB P1.0,KB2 JNB P1.0,$ JB P0.0,KB2 CLR P2.2 MOV 20H,#0FEH JMP KENV KB2:JB P1.1,KB3 JNB P1.1,$ JB P0.1,KB3// CLR P2.2 MOV 20H,#0FDH JMP KENV KB3:JB P1.2,KB4 JNB P1.2,$ JB P0.2,KB4 CLR P2.2 MOV 20H,#0FBH JMP KENV KB4:JB P1.3,KB5 JNB P1.3,$ JB P0.3,KB5 CLR P2.2 MOV 20H,#0F7H JMP KENV KB5:JB P1.4,KB6 JNB P1.4,$ JB P0.4,KB6 CLR P2.2 MOV 20H,#0EFH JMP KENV KB6:JB P1.5,KENV JNB P1.5,$ JB P0.5,KENV CLR P2.2 MOV 20H,#0DFH KENV: JB P3.0,KB1 JNB P3.0,$ JB P2.2,KB1 ACALL DELAY2S SETB P2.4 CLR P2.5 ACALL DELAY2S MOV A,20H CJNE A,#0FEH,NB1 SETB P2.5 // CLR P0.0 ACALL DELAY2S SETB P0.0 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NB1: CJNE A,#0F7H,NB2 SETB P2.5 // CLR P0.3 ACALL DELAY2S SETB P0.3 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NB2: SETB P2.5 CLR P2.6 ACALL DELAY2S CJNE A,#0FDH,NB3 SETB P2.6 // CLR P0.1 ACALL DELAY2S SETB P0.1 CLR P2.6 ACALL DELAY2S SETB P2.6 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NB3: CJNE A,#0EFH,NB4 SETB P2.6 // CLR P0.4 ACALL DELAY2S SETB P0.4 CLR P2.6 ACALL DELAY2S SETB P2.6 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NB4: SETB P2.6 CLR P2.7 ACALL DELAY2S CJNE A,#0FBH,NB5 SETB P2.7 // CLR P0.2 ACALL DELAY2S SETB P0.2 CLR P2.7 ACALL DELAY2S SETB P2.7 CLR P2.6 ACALL DELAY2S SETB P2.6 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 JMP LOOP NB5: CJNE A,#0DFH,NB6 SETB P2.7 // CLR P0.5 ACALL DELAY2S SETB P0.5 CLR P2.7 ACALL DELAY2S SETB P2.7 CLR P2.6 ACALL DELAY2S SETB P2.6 CLR P2.5 ACALL DELAY2S SETB P2.5 CLR P2.4 NB6: JMP LOOP DELAY2S:MOV R1,#8 DELA1:MOV R2,#255 DELA2:MOV R3,#100 DELA3:NOP NOP DJNZ R3,DELA3 DJNZ R2,DELA2 DJNZ R1,DELA1 RET END
完整汇编程序下载地址: http://www.51hei.com/f/ck.rar
上一篇:光驱简易遥控器
下一篇:点阵+音乐=祝你生日快乐
推荐阅读最新更新时间:2024-03-16 13:07