当前位置:文档之家› 饮料包装流水线

饮料包装流水线

data segmentioport equ 2400h-280hio8255a equ ioport+288hio8255c equ ioport+28Ahio8255ctr equ ioport+28bhled db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fhtime db '0','$'time_1 db '0','$'time_2 db '0','$'time_3 db '0','$'time_4 db '0','$'time_5 db '0','$'time_6 db '0','$'ten db 10num db 0num1 db 0temp db 12temp1 db '0','$'temp2 db 0temp3 db 0mess db 'Press Q to EXIT',0ah,0dh,'$'xiang db 'CASE','$'ping db '12 BOTTLE Date:','$'waittime db 'wait 5s packing...',0ah,0dh,'$'time_ok db 'packing is finished!',0ah,0dh,'$'wrong db 'marchine is broken!',0ah,0dh,'$'right db 'machine is ok now!',0ah,0dh,'$'run db 'machine is running...',0ah,0dh,'$'data endscode segmentmain proc farassume cs:code,ds:datastart:mov ax,datamov ds,axmov dx,offset mess ;显示提示信息mov ah,09hint 21hmov dx, io8255ctr ;将8255设为A口输出,c口4-7输入0-3输出mov al,10001000bout dx,almov dx,2403h ;开始对8253进行初始化mov al,00010000b;计数器0方式0低八位二进制out dx,almov dx,2400hmov al,12out dx,al ;设置计数初值mov dx, io8255ctr ;c口第四位pc4置0,默认无故障mov al,00001000bout dx,almov dx,offset run;显示machine is runningmov ah,09hint 21hll:mov dx,io8255cmov al,00001000bout dx,almov dx,io8255cin al,dxand al,00010000b ;检测PC4jz a ;转到amov dx,offset wrong;marchine is brokenmov ah,09hint 21hmov dx,io8255ctr;出现故障,则需要将pc3即运行灯关掉mov al,00000110bout dx,alguzhang:mov dx,io8255c ;循环判断机器是否还是处在故障中in al,dxand al,00010000bjz guzhang;mov dx,offset right;machine is ok nowmov ah,09hint 21hmov dx,io8255a ;故障处理完后,机器进入正常运行态mov al,00000111b;PC3正常运行点亮out dx,almov dx,offset run;machine is runningmov ah,09ha:mov dx,2400h ;将2400口(计数器0)的数据打到dx in al,dx;cmp al,-1;jle a;结果小于或等于-1转移amov bl,temp ;12sub bl,al ;bl中的内容减去al中的,并重新放入bl中mov al,bl ;将16进制转换成10进制add al,1mov temp3,almov ah,0 ;高位清零div tenmov temp1,ah ;将个位放入temp1中mov bx,offset led ;bx为数码表的起始地址xlat ;求出相应的段码mov dx, io8255aout dx,al;送给数码管mov dx, io8255cmov al,02h;十位数码管out dx,almov al,0mov dx, io8255aout dx,almov dx, io8255cmov al,01h;个位数码管out dx,almov al,temp1;个位xlat ;求出相应的段码mov dx, io8255aout dx,al ;显示个位mov dx, io8255cmov al,01hout dx,almov al,0mov dx, io8255a;显示十位out dx,almov dx, io8255cmov al,02hout dx,alcmp temp3,13;不相等转tadd num,1 ;计数打包灯亮mov dx,io8255ctrmov al,00000101b;out dx,alcall delaycall draw ;显示时间子程序mov dx,2400hmov al,12out dx,al ;设置计数初值`t: mov ah,06h ;测键盘,有Q键按下,退出mov dl,0ffhint 21hcmp al,'q'je exithlt ;系统暂停jmp ll;检测有无故障exit: mov ah,4ch;放回操作系统int 21hdelay proc nearmov dx,offset waittime ;wait 5s packingmov ah,09hint 21h ;输出字符串push axpush bxpush dxmov ah,0hint 1ahadd dx,91mov bx,dxrep1:mov ah,0hint 1ah ;读当前时钟cmp dx,bxjnz rep1;装箱mov dx,offset time_ok ;packing is finishedmov ah,09hint 21h ;输出字符串mov dl,numcmp dl,09h ;小于9转yjle ymov al,dlmov ah,00h ;十位此时显示0div tenpush axmov dl,aladd dl,30hmov ah,02hint 21hpop axmov dl,ahadd dl,30hmov ah,02h;十位int 21hjmp y1y: add dl,30hmov ah,02hint 21hy1: mov dl,32 ;输出空格mov ah,02hint 21hmov dx,offset xiang ;将xiang的偏移地址给dx “CASE”mov ah,09hint 21h ;输出字符串mov dl,32;输出空格mov ah,02hint 21hmov dx,offset ping;'12 BOTTLE Date:mov ah,09hint 21hpop dxpop bxpop axretdelay endpdraw proc near ;显示时间子程序;2AH号调用: 取日期功能:取系统日期。

;入口参数: 无。

出口参数: CX=年,DH: DL=月: 日。

;调用方式: MOV AH,2AH; INT 21H在(CX)中取得年号,在DX中的高8位取得月份,低8位中得到日(二进制).mov ax,datamov ds,axmov ah,2ah ;取系统日期int 21hmov time_5,dh ;进行数制转换mov time_6,dlmov ax,cxdiv tenmov time,ahmov ah,0div tenmov time_4,ahmov ah,0div tenmov time_3,ahmov dl,al ;将转换好的在转换成ASCII码add dl,30hmov ah,02hint 21hmov dl,time_3add dl,30hmov ah,02h ;输出int 21hmov dl,time_4add dl,30h ;将转换好的在转换成ASCII码mov ah,02h ;输出int 21hmov dl,timeadd dl,30hmov ah,02hint 21h;年的转换mov dl,47mov ah,02hint 21h ;/符号输出mov al,time_5mov ah,0div tenmov time,ahmov dl,aladd dl,30hmov ah,02hint 21hmov dl,timeadd dl,30hmov ah,02hint 21h ;月的转换mov dl,47mov ah,02hint 21h ;/符号输出mov al,time_6mov ah,0div tenmov time,ahmov dl,aladd dl,30hmov ah,02hint 21hmov dl,timeadd dl,30hmov ah,02hint 21h ;日的转换mov dl,32mov ah,02hint 21h;空格输出mov ah,2ch ; 取系统时间int 21h ;2ch号功能调用,取系统时间:ch,cl,dh中分别存放时分秒mov time,dhmov al,chmov ah,0;mov bl,10div tenadd al,30hmov time_1,almov bl,ahmov dx,offset time_1 ;将time_1的偏移地址放入dx中mov ah,09h ;输出time_1中的内容int 21hadd bl,30h ;转换成ASCII码mov time_2,blmov dx,offset time_2 ;将time_2的偏移地址放入dx中mov ah,09h ;输出time_2中的内容int 21hmov dl,58 ; :符号的输出mov ah,02hint 21hmov al,clmov ah,0div tenmov time_4,ahmov dl,aladd dl,30h ;转换成ASCII码mov ah,02hint 21hmov dl,time_4add dl,30h ;转换成ASCII码mov ah,02hint 21hmov dl,58mov ah,02hint 21hmov al,time ; 显示秒mov ah,0div tenmov time_3,ahmov dl,aladd dl,30hmov ah,02hint 21hmov dl,time_3add dl,30hmov ah,02hint 21hmov dl,0dhint 21h ;回车mov dl,0ahint 21hmov dl,0dhint 21h ;回车mov dl,0ahint 21hretdraw endp ;显示时间子程序结束main endpcode ends end start。

相关主题