?? lamp.asm
字號:
;386以上微機適用
;純dos下才能使用
;tasm4.1或以上編譯
;*********************;
;* 8253 *;
;*********************;
io_plx_device_id equ 05406h ;TPC卡設備ID
io_plx_vendor_id equ 010b5h ;TPC卡廠商ID
IO_PLX_SUB_ID EQU 0905410B5H ;TPC卡子設備及廠商ID
pa55 equ 218h-200H ;8255端口地址
pb55 equ 219h-200H
pc55 equ 21ah-200H
p55ctl equ 21bh-200H
data segment
io_base_address db 4 DUP(0) ;TPC卡I/O基地址暫存空間
pcicardnotfind db 0dh,0ah,'TPC pci card not find or address/interrupt error !!!',0dh,0ah,'$'
iobaseaddress db 0dh,0ah,'TPC pci card I/O Base Address : ','$'
enter_return db 0dh,0ah,'$'
pb db ?
mess db 'Enter any key can exit to dos!',0dh,0ah,'$'
data ends
stacks segment
db 100 dup (?)
sta dw 50 dup(?)
top equ length sta
stacks ends
code segment
assume cs:code,ds:data,ss:stacks,es:data
start:
.386
cli
mov ax,data
mov ds,ax
mov es,ax
mov ax,stacks
mov ss,ax
call findtpc ;查找TPC卡資源并顯示
mov ah,09h
mov dx,offset mess
int 21h
MOV DX,word ptr io_base_address ;初始化8255
add dx,p55ctl
mov al,82h
out dx,al
MOV DX,word ptr io_base_address
add dx,pb55
in al,dx
mov pb,al
MOV DX,word ptr io_base_address
add dx,p55ctl
mov al,80h
out dx,al
MOV DX,word ptr io_base_address
add dx,pb55
mov al,pb
or al,0f0h
out dx,al ;turn off yellow
MOV DX,word ptr io_base_address
add dx,pc55
mov al,0f0h ;4 red lights
out dx,al
call delay10
lll:
mov al,10100101b ;turn on 1,3 green light
MOV DX,word ptr io_base_address
add dx,pc55
out dx,al
call delay10
call delay10
or al,0f0h ; turn off 1,3 green light
out dx,al
mov cx,0008h
ttt:
MOV DX,word ptr io_base_address
add dx,pb55
mov al,pb
and al,10101111b ; 1,3 yellow light turn on
out dx,al
call delay1
or al,01010000b
out dx,al ; 1,3 yellow light turn off
call delay1
loop ttt
MOV DX,word ptr io_base_address
add dx,pc55
mov al,0f0h
out dx,al
call delay1
mov al,01011010b
out dx,al ; 2,4 green 1,3 red
call delay10
call delay10
or al,0f0h ; turn off 2,4 green light
out dx,al
mov cx,0008h
ggg:
MOV DX,word ptr io_base_address
add dx,pb55
mov al,pb
and al,01011111b
out dx,al ; turn on 2,4 yellow
call delay1
or al,10100000b
out dx,al ; turn off 2,4 yellow
call delay1
loop ggg
MOV DX,word ptr io_base_address
add dx,pc55
mov al,0f0h
out dx,al
call delay1
mov ah,06h
mov dl,0ffh
int 21h
jnz ppp
jmp lll
ppp:
mov ax,4c00h
int 21h ;退出
delay1 proc near
push cx
mov cx,0ffffh
ccc:
loop ccc
pop cx
ret
delay1 endp
delay10 proc near
push ax
push cx
mov cx,0100h
uuu:
call delay1
loop uuu
pop cx
pop ax
ret
delay10 endp
findtpc proc near ;查找TPC卡資源并顯示
pushad
pushfd
MOV AX,0B101H
INT 1AH
JC findtpc_notfind ;檢查PCI BIOS是否存在
MOV AX,0B102H
MOV CX,io_plx_device_id
MOV DX,io_plx_vendor_id
MOV SI,0
INT 1AH
JC findtpc_notfind ;檢查TPC卡是否安裝,設備號、廠商號
MOV AX,0B10AH
MOV DI,02CH
INT 1AH
JC findtpc_notfind
CMP ECX,IO_PLX_SUB_ID
JNZ findtpc_notfind ;檢查TPC卡是否安裝,子設備號、廠商號
MOV AX,0B10AH
MOV DI,18H
INT 1AH
JC findtpc_notfind ;讀TPC卡I/O基址信息
mov dword ptr io_base_address,ecx
and ecx,1
jz findtpc_notfind ;檢查是否為i/o基址信息
mov ecx,dword ptr io_base_address
and ecx,0fffffffeh
mov dword ptr io_base_address,ecx ;去除i/o指示位并保存
mov dx,offset iobaseaddress ;顯示i/o提示信息
mov ah,09h
int 21h
mov ax,word ptr io_base_address
call dispword ;顯示i/o基地址
mov dx,offset enter_return ;加回車符,換行符
mov ah,09h
int 21h
popfd
popad
ret
findtpc_notfind:
mov dx,offset pcicardnotfind ;顯示未找到tpc卡提示信息
mov ah,09h
int 21h
mov ax,4c00h
int 21h ;退出
findtpc endp
dispword proc near ;顯示子程序
push dx
push cx
push bx
mov cx,4
mov bx,16
dispword_loop1:
push ax
push cx
sub bx,4
mov cx,bx
shr ax,cl
and al,0fh ;首先取低四位
mov dl,al
cmp dl,9 ;判斷是否<=9
jle dispword_num ;若是則為'0'-'9',ASCII碼加30H
add dl,7 ;否則為'A'-'F',ASCII碼加37H
dispword_num:
add dl,30h
mov ah,02h ;顯示
int 21h
pop cx
pop ax
loop dispword_loop1
pop bx
pop cx
pop dx
ret ;子程序返回
dispword endp
code ends
end start
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -