⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trlight.asm

📁 是模拟交通灯亮灭规律的小程序,是并口的实验
💻 ASM
字号:
pa55 equ 0dc00h-200h+218h
pb55 equ 0dc00h-200h+219h
pc55 equ 0dc00h-200h+21ah
p55ctl equ 0dc00h-200h+21bh

bright MACRO kou,method
        push ax
        push bx
        push cx
        push dx

       mov al,method           
       mov dx,kou
       out dx,al         

        pop dx
        pop cx
        pop bx
        pop ax
ENDM

flashbright macro method

        push ax
        push bx
        push cx
        push dx

       mov al,method           
       mov dx,pb55
       out dx,al  

        pop dx
        pop cx
        pop bx
        pop ax

endm

flashdark macro method

        push ax
        push bx
        push cx
        push dx

       mov al,00h  
       mov dx,pb55
       out dx,al             

        pop dx
        pop cx
        pop bx
        pop ax

endm


data   segment
d1  db 'enter any key to exit $'
data ends

code   segment
       assume ds:data,cs:code
start: mov ax,data
       mov ds,ax
                          ;九号功能调用,显示字符串
       lea dx,d1
       mov ah,9
       int 21h

       mov al,90h          ;置8255控制字,都输出
       mov dx,p55ctl
       out dx,al

       bright pc55,0fh   ;c口l5-l7亮(pc4-pc7),4个口红灯全亮

       call delay

begin:
       bright pc55,01011010b    ;13口绿灯亮,24口红灯亮 

       call delay

       bright pc55,00001010b     ;13口绿灯灭
 
       flashbright 01010000b       ;13口黄灯亮
       call minidelay
       flashdark 00h               ;13口黄灯灭 
       call minidelay
       flashbright 01010000b       ;13口黄灯亮
       call minidelay
       flashdark 00h               ;13口黄灯灭 
       call minidelay
       flashbright 01010000b       ;13口黄灯亮
       call minidelay
       flashdark 00h               ;13口黄灯灭 
       call minidelay
       flashbright 01010000b       ;13口黄灯亮
       call minidelay
       flashdark 00h               ;13口黄灯灭    
                
       bright pc55,10100101b    ;24口绿灯亮,13口红灯亮 

       call delay

       flashbright 10100000b       ;24口黄灯亮
       call minidelay
       flashdark 00h               ;24口黄灯灭 
       call minidelay
       flashbright 10100000b       ;24口黄灯亮
       call minidelay
       flashdark 00h               ;24口黄灯灭 
       call minidelay
       flashbright 10100000b       ;24口黄灯亮
       call minidelay
       flashdark 00h               ;24口黄灯灭 
       call minidelay
       flashbright 10100000b       ;24口黄灯亮
       call minidelay
       flashdark 00h               ;24口黄灯灭         

      bright pc55,0fh   ;c口l5-l7亮(pc4-pc7),4个口红灯全亮

      mov ah,01h         ;判断是否有键按下,若有则推出
      int 16h
      jnz exit
      call delay
      jmp begin
   
exit:
       mov ah,4ch
       int 21h

delay proc near               ;延时
   
      push ax
      push bx
      push cx
      push dx

      mov cx,5000
loop4:
      loop loop4

      pop dx
      pop cx
      pop bx
      pop ax
      ret
      delay endp


minidelay proc near               ;延时
   
      push ax
      push bx
      push cx
      push dx

      mov cx,2000
loop5:
      loop loop5

      pop dx
      pop cx
      pop bx
      pop ax
      ret
      minidelay endp



code   ends
       end  start

⌨️ 快捷键说明

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