用汇编编程实现检测外部设备输出不对帮看看
;tab macro var;lea dx,var
; mov ah,09h
;int 21h
;endw
.model small
.386
data segment
BN db 0dh,0ah,'bus number:','$'
DN db 0dh,0ah,'device number:','$'
FN db 0dh,0ah,'function number:','$'
vid_did db 0dh,0ah,'vendor ID/device ID:','$'
lls db 0dh,0ah,'link speed 2.5','$'
hls db 0dh,0ah,'link speed 5and2.5','$'
x1lw db 0dh,0ah,'width x1','$'
x2lw db 0dh,0ah,'width x2','$'
x4lw db 0dh,0ah,'width x4','$'
x8lw db 0dh,0ah,'width x8','$'
x12lw db 0dh,0ah,'width x12','$'
x16lw db 0dh,0ah,'width x16','$'
x32lw db 0dh,0ah,'width x32','$'
data ends
.stack
code segment
assume cs:code,ds:data,ss:stack
main proc far
mov dx,data
mov ds,dx
mov ecx,80000000h
start:
mov eax,ecx
mov dx,0cf8h
out dx,eax
mov dx,0cfch
in eax,dx
cmp eax,0ffffffffh
je exit
push ecx
push eax
rol ecx,16
; push ecx
mov ebx,ecx
lea dx,BN
mov ah,09h
int 21h
call d
; pop ecx
rol ecx,5
;push ecx
mov ebx,ecx
lea dx,DN
mov ah,09h
int 21h
and al,1fh
call d
; pop ecx
rol ecx,3
; push ecx
mov ebx,ecx
lea dx,FN
mov ah,09h
int 21h
and bl,07h
call d
; pop ecx
rol ecx,8
;push ecx
lea dx, vid_did
mov ah,09h
int 21h
pop eax
; push ecx
mov ebx,eax
call display
pop ecx
mov eax,ecx
or eax,30h
mov dx,0cf8h
out dx,eax
mov dx,0cfch
in eax,dx
push ecx
mov ebx,eax
test ebx,1h
jnz x2g
test ebx,2h
jnz x5g
cb: test ebx,10h
jnz x1
test ebx,20h
jnz x2
test ebx,40h
jnz x4
test ebx,80h
jnz x8
test ebx,0c0h
jnz x12
test ebx,100h
jnz x16
test ebx,200h
jnz x32
e: pop ecx
add ecx,100h
cmp ecx,80fffff0h
jl start
mov ah,4ch
int 21h
x2g: lea dx,lls
mov ah,09h
int 21h
jmp cb
x5g: lea dx,hls
mov ah,09h
int 21h
jmp cb
x1: lea dx,x1lw
mov ah,09h
int 21h
jmp e
x2: lea dx,x2lw
mov ah,09h
int 21h
jmp e
x4: lea dx,x4lw
mov ah,09h
int 21h
jmp e
x8: lea dx,x8lw
mov ah,09h
int 21h
jmp e
x12: lea dx,x12lw
mov ah,09h
int 21h
jmp e
x16: lea dx,x16lw
mov ah,09h
int 21h
jmp e
x32: lea dx,x32lw
mov ah,09h
int 21h
jmp e
exit: add ecx,100h
cmp ecx,80fffff0h
jl start
mov ah,4ch
int 21h
main endp
display proc near
mov ch,8
rotate: mov cl,4 ;set count to 4 bits
rol ebx,cl ;left digit to right
mov al,bl ; move to AL
and al,0fh ;mask off left digit
add al,30h ;convert hex to ASCII
cmp al,3ah ;is it > 9 ?
jl printit ;jump if digit = 0 to 9
add al,7h ;digit is A to F
printit:
mov dl,al ;put ASCII char in DL
mov ah,2 ;display output funct
int 21h ;call DOS
dec ch ;done 4 digits ?
jnz rotate ;not yet
ret
display endp
d proc near
mov ch,2
t:rol bl,4
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl r
add al,7h
r: mov dl,al
mov ah,2h
int 21h
dec ch
jnz t
ret
d endp
crlf proc near
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21h
ret
crlf endp
code ends
end main