ASM 板


LINE

看板 ASM  RSS
請問各位高手 我在寫一個 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)
1F:→ eentut:function 3 bit : range 0x00~0x07 11/05 22:54
2F:→ eentut:device 5 bit : range 0x00~0x1F 11/05 22:54
3F:→ eentut:bus 8 bit : range 0x00~0xFF 11/05 22:55
4F:→ eentut:Register range : 0x00~0xFF 11/05 22:55
5F:→ eentut:你知道自己錯在哪了嗎? 11/05 22:56







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:BuyTogether站內搜尋

TOP