[問題] 程式無法正常結束
請問各位高手
我在寫一個 PCI SCAN 的程式
可以 SCAN 到所有的 DEVICE
但是當我按 pgdn 到最後一個 DEVICE
然後再按 pgdn 程式就會死當...
可以請各位幫我 DEBUG 一下嗎?
我看了很久,覺得我的邏輯並沒有錯誤
還是我有語法哪裡錯了呢?感謝各位!
以下為程式碼:
.model small
.586
.stack
.data
bus db 'Bus_num: $'
device db 'Device_num:$'
function db 'Function_num:$'
test1 db 'test****************$'
bus_num dd 0
dev_num dd 0
func_num dd 0
reg_num dd 0
row db ?
count db 4
col_flag db 0
msg_flag db 0
.code
begin:
mov ax, @data
mov ds, ax
mov dl,0
main_func: call clear_bot
call clear_head
mov bus_num,0
.REPEAT
mov dev_num,0
.REPEAT
mov func_num,0
.REPEAT
mov reg_num,0
mov msg_flag,0
mov row,3
reg_count: mov ah,02
.IF(col_flag == 0)
mov dl,0
.ENDIF
mov dh,row
mov bh,0
int 10h
mov eax,reg_num
mov edx,func_num
shl edx,8
or eax,edx
mov edx,dev_num
shl edx,11
or eax,edx
mov edx,bus_num
shl edx,16
or eax,edx
or eax,80000000h
mov dx,0cf8h
out dx,eax
mov cx,0cfch
.REPEAT
push cx
mov dx,cx
in ax,dx
mov bx,ax
;--------- decide whether the PCI exists or not---------
.IF bx == 0ffffh
.IF func_num == 0 && reg_num == 0 ;the PCI doesn`t exist
jmp dev_loop
.ELSEIF func_num != 0 && reg_num == 0 ;the PCI exists,
and scan its functions
jmp func_loop
.ELSEIF func_num == 0 && reg_num != 0 || func_num !=0 &&
reg_num != 0
call print_hex
mov dl,' '
mov ah,2
int 21h
.ENDIF
.ELSE
.IF (reg_num == 0 && msg_flag == 0)
call msg
mov msg_flag,1
jmp reg_count
.ENDIF
call print_hex
mov dl,' '
mov ah,2
int 21h
.ENDIF
;-------------------------------------------------------
pop cx
add cx,2
.UNTIL(cx == 0d00h)
mov ah,03h
mov bh,0
int 10h
add reg_num,4
dec count
mov col_flag,1
jnz reg_count
mov count,4
call clear_tail
inc row
mov col_flag,0
.IF row == 23 || reg_num == 256
call clear_r2
call press_key
.ELSE
jmp reg_count
.ENDIF
func_loop: inc func_num
.UNTIL(func_num == 8)
dev_loop: inc dev_num
.UNTIL(dev_num == 32)
inc bus_num
.IF bus_num == 256;-----------
mov dx,offset test1
mov ah,9
int 21h
.ENDIF
.UNTIL(bus_num == 256)
exit: mov ax,4c00h
int 21h
press_key proc near
;------- press button to act ---------
print_page: mov eax,0
int 16h
cmp ah,01h; esc_key
je exit
cmp ah,51h; pgdn_key
je func_loop
;-------------------------------------
;pgdn: func_loop
ret
press_key endp
;********** print out where the PCI locates on ***********
;------------------------------------
msg proc near
mov ah,2
mov dl,0
mov dh,1
mov bh,0
int 10h
mov dx,offset bus
mov ah,9
int 21h
call print_bus_num
mov dx,' '
mov ah,2
int 21h
mov dx,offset device
mov ah,9
int 21h
call print_dev_num
mov dx,' '
mov ah,2
int 21h
mov dx,offset function
mov ah,9
int 21h
call print_func_num
ret
msg endp
;-------------------------------------
;-------- print out BUS# ---------
print_bus_num proc near
mov ecx,bus_num
rol cl,4
call print_out
rol cl,4
call print_out
ret
print_bus_num endp
;---------------------------------
;-------- print out DEVICE# ---------
print_dev_num proc near
mov ecx,dev_num
rol cl,4
call print_out
rol cl,4
call print_out
ret
print_dev_num endp
;---------------------------------
;-------- print out FUNCTION# ---------
print_func_num proc near
mov ecx,func_num
rol cl,4
call print_out
rol cl,4
call print_out
ret
print_func_num endp
;---------------------------------
print_out proc near
mov dx,cx
and dl,0fh
add dl,30h
cmp dl,3ah
jb print2
add dl,7
print2: mov eax,0
mov ah,2
int 21h
ret
print_out endp
;********************************************************
;********** print out the value of registers ************
print_hex proc near
rol bx,8
rol bx,4
call print_4_bits
rol bx,4
call print_4_bits
mov ah,2
mov dl,' '
int 21h
rol bx,4
call print_4_bits
rol bx,4
call print_4_bits
ret
print_hex endp
print_4_bits proc near
mov dx,bx
and dl,0fh
add dl,30h
cmp dl,3ah
jb print1
add dl,7
print1: mov eax,0
mov ah,2
int 21h
ret
print_4_bits endp
;********************************************************
;****************** clear monitor ***********************
clear_r2 proc near
mov ah,2
mov dl,0
mov dh,2
mov bh,0
int 10h
mov cx,50
clr: mov dl,' '
mov ah,2
int 21h
loop clr
ret
clear_r2 endp
clear_tail proc near
mov ah,2
mov dh,row
mov bh,0
int 10h
mov cx,40
clr: mov dl,' '
mov ah,2
int 21h
loop clr
ret
clear_tail endp
clear_head proc near
mov ah,2
mov dh,0
mov dl,0
mov bh,0
int 10h
mov cx,50
clr: mov dl,' '
mov ah,2
int 21h
loop clr
ret
clear_head endp
clear_bot proc near
mov ah,2
mov dh,19
cont: mov dl,0
mov bh,0
int 10h
mov cx,50
clr: mov dl,' '
mov ah,2
int 21h
loop clr
inc dh
cmp dh,25
jne cont
ret
clear_bot endp
;********************************************************
end begin
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 124.9.5.2
※ 編輯: morganc 來自: 124.9.5.2 (11/01 17:39)
→
11/05 22:54, , 1F
11/05 22:54, 1F
→
11/05 22:54, , 2F
11/05 22:54, 2F
→
11/05 22:55, , 3F
11/05 22:55, 3F
→
11/05 22:55, , 4F
11/05 22:55, 4F
→
11/05 22:56, , 5F
11/05 22:56, 5F
ASM 近期熱門文章
PTT數位生活區 即時熱門文章