📄 sw.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,'$'
tab db '1 2 3 4 5 6 7 8 9 10 11 12 ',0dh,0ah,'$'
mess db 'Please enter any key when ready!',0dh,0ah,'$'
mes db 0dh,0ah,'$'
data ends
stacks segment
db 100 dup (?)
sta dw 50 dup(?)
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 ah,01h
;int 21h
goon:
MOV DX,word ptr io_base_address ;初始化8255
add dx,p55ctl
mov al,8bh
out dx,al
MOV DX,word ptr io_base_address
add dx,pb55
in al,dx
mov bh,al
MOV DX,word ptr io_base_address
add dx,pc55
in al,dx
mov bl,al
mov ah,09h
mov dx,offset mes
int 21h
mov cl,04h
shr bh,cl
a1: mov dl,bh
call disp
shr bh,1
dec cl
jnz a1
mov cx,0008h
bbb: mov dl,bl
call disp
shr bl,1
loop bbb
sti
mov ah,01h
int 16h
jz goon
mov ax,4c00h
int 21h ;退出
disp proc near
push ax
and dl,01h
add dl,30h
mov ah,02h
int 21h
mov dl,20h
int 21h
int 21h
pop ax
ret
disp 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 + -