最后选用可编程并行接口8255A完成的交通灯实验.txt

来自「该程序是为可编程并行接口8255A完成的交通灯实验」· 文本 代码 · 共 469 行

TXT
469 行
字号
  用8255A的B端口和C端口控制12个LED的亮和灭(输出为0则亮,输出为1则灭),模拟十字路口的交通灯。              备注:硬件实验


 


 CCW


 
 


 data    segment



data1   db 'traficlight system','$'



data    ends



code    segment



        assume cs:code,ds:data



start:  mov ax,data



        mov ds,ax



        lea dx,data1



        mov ah,09h



        int 21h



        mov dx,21bh



        mov al,10000010b



        out dx,al



        mov dx,219h



        in al,dx



        mov bl,al



        mov dx,21bh



        mov al,10000000b



        out dx,al



        mov dx,219h



        mov al,0ffh



        out dx,al



        mov dx,21ah



        mov al,0f0h



        out dx,al



        call delay1



l1:     mov al,10100101b



        out dx,al



        call delay1



        mov al,0f5h



        out dx,al



        call loop1



l3:     mov dx,21ah



        mov al,5ah



        out dx,al



        call delay1



        



        



        



        mov al,0fah



        out dx,al



        call loop2



        mov dx,21ah



        mov al,11111111b



        out dx,al



        mov ah,0bh



        int 21h



        cmp al,00h



        je l1



l7:     mov ah,4ch



        int 21h



delay   proc



        mov ah,0bh



        int 21h



        cmp al,00h



        jne l7



        mov cx,2000h



l4:     push cx



        mov cx,2000



l5:     loop l5



        pop cx



        loop l4



        ret



delay   endp



loop1   proc



        mov ah,0bh



        int 21h



        cmp al,00h



        jne l7



        mov cx,8



l6:     mov dx,219h



        mov al,10101111b



        out dx,al



        push cx



        call delay



        pop cx



        mov al,0ffh



        out dx,al



        push cx



        call delay



        pop cx



        loop l6



        ret



loop1   endp



loop2   proc



        mov ah,0bh



        int 21h



        cmp al,00h



        jne l7



        mov cx,8



l9:     mov dx,219h



        mov al,5fh



        out dx,al



        push cx



        call delay



        pop cx



        mov al,0ffh



        out dx,al



        push cx



        call delay



        pop cx



        loop l9



        ret



loop2   endp



delay1  proc



        mov cx,10



l8:     push cx



        call delay



        pop cx



        loop l8



        ret



delay1  endp



code    ends



        end start

 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?