将pci地址存储在内存中并显示

发布于 2025-01-18 04:09:19 字数 3096 浏览 2 评论 0原文

运行屏幕

对不起,英语不是我的母语,所以请原谅任何错误。

当我读取PCI地址(从80000000H)时,我尝试确定其是否是有效的地址(不等于FFFFH),并将有效地址存储在变量地址中,并将其读取。 但是我的代码似乎无法实现它。阅读时,它不会显示存储的内容,但有些乱七八糟。 我不知道这是存储或阅读的错误方法,我仍然是使用偏移访问的新手。

.MODEL SMALL
.486P
.DATA
;-----------------------------------------
rowx     db ?
count     db ?
address  dw 500 dup(?)
fun      db 0
bus      db ?
dev      db ?
.STACK  500
.CODE
;*****************************************

pcitool proc near
    open_11:
        mov esi,offset address
        mov edi,80000000h   
        
        mov count,0    ;Count the number of devices
        mov rowx,0     ;like 'count' 
        
    loopaa: 
        push cx
        
        mov eax,edi     ;read address
        mov dx,0cf8h
        out dx,eax
        mov dx,0cfch
        in  eax,dx
        
        cmp ax,0ffffh   ;Comparison
        jz  again1      ;if equal to ffffh move next loop
        mov eax,edi     ;else store it
        ;----------
        push eax
                
        mov  cl,16
        shr  eax,cl
        and al, 80h
        mov  bus,al        ;check bus
        
        pop eax
        push eax
        
        mov  cl,11
        shr  eax,cl
        and  al,1fh    ;check device
        mov  dev,al
        
        pop eax
        push eax
        
        mov eax,edi     ;else store it
        mov cl,8
        shr eax,cl
        and al,07h
        mov fun,al        ;check function
        
        pop eax

           ;---------------------

        inc rowx        ;add dev
        
        mov eax,edi
        shr eax,8
        mov [esi],ax
        add esi,2

        ; mov [esi],edi           ;store
        ; add esi,4               

        cmp fun,0       ;have function?
        jnz again1      ;yes -> again
        
        ; add edi,0ch     ;no function
        ; mov eax,edi     ;addr+12
        lea eax, [edi+0ch]
        
        mov dx,0cf8h            ;read
        out dx,eax
        mov dx,0cfch
        in  eax,dx
        
        sub edi,0ch     
        mov cl,16   
        shr eax,cl      
        and al,80h
        
        cmp al,0
        jnz again1
        jnz again1
        add edi,700h
        
    again1: 
        add edi,100h
        cmp edi,81000000h
        jb loopaa
        
;------------------read from memory-----------------

    opena:  
        mov esi,offset address


    loopa: 
        mov eax,[esi]
        
        mov  cl,16
        shr  eax,cl
        mov dl,al
        mov ah,02h
        int 21h

        mov  cl,11
        shr  eax,cl
        and  al,1fh    ;check device
        mov dl,al
        mov ah,02h
        int 21h

        mov cl,8
        shr eax,cl
        and al,07h
        mov dl,al
        mov ah,02h
        int 21h
        

        inc count        ;account
    again: 
        mov al,rowx
        cmp count,al
        jz endd
        add esi,4
        loop loopa         ;loop read
    
    endd:
        mov     ax,4c00h    ;esc
        int     21h
        ret

pcitool   endp

run screen

Sorry, English isn’t my first language, so please excuse any mistakes.

When I read the pci address(from 80000000h), I try to determine whether it is a valid address (not equal to ffffh), and store the valid address in the variable address, and read it in the next loop.
But my code doesn't seem to be able to achieve it. When reading, it does not display the stored content, but some garbled.
I don't know if it's the wrong way to store or read it, I'm still new to using offset access.

.MODEL SMALL
.486P
.DATA
;-----------------------------------------
rowx     db ?
count     db ?
address  dw 500 dup(?)
fun      db 0
bus      db ?
dev      db ?
.STACK  500
.CODE
;*****************************************

pcitool proc near
    open_11:
        mov esi,offset address
        mov edi,80000000h   
        
        mov count,0    ;Count the number of devices
        mov rowx,0     ;like 'count' 
        
    loopaa: 
        push cx
        
        mov eax,edi     ;read address
        mov dx,0cf8h
        out dx,eax
        mov dx,0cfch
        in  eax,dx
        
        cmp ax,0ffffh   ;Comparison
        jz  again1      ;if equal to ffffh move next loop
        mov eax,edi     ;else store it
        ;----------
        push eax
                
        mov  cl,16
        shr  eax,cl
        and al, 80h
        mov  bus,al        ;check bus
        
        pop eax
        push eax
        
        mov  cl,11
        shr  eax,cl
        and  al,1fh    ;check device
        mov  dev,al
        
        pop eax
        push eax
        
        mov eax,edi     ;else store it
        mov cl,8
        shr eax,cl
        and al,07h
        mov fun,al        ;check function
        
        pop eax

           ;---------------------

        inc rowx        ;add dev
        
        mov eax,edi
        shr eax,8
        mov [esi],ax
        add esi,2

        ; mov [esi],edi           ;store
        ; add esi,4               

        cmp fun,0       ;have function?
        jnz again1      ;yes -> again
        
        ; add edi,0ch     ;no function
        ; mov eax,edi     ;addr+12
        lea eax, [edi+0ch]
        
        mov dx,0cf8h            ;read
        out dx,eax
        mov dx,0cfch
        in  eax,dx
        
        sub edi,0ch     
        mov cl,16   
        shr eax,cl      
        and al,80h
        
        cmp al,0
        jnz again1
        jnz again1
        add edi,700h
        
    again1: 
        add edi,100h
        cmp edi,81000000h
        jb loopaa
        
;------------------read from memory-----------------

    opena:  
        mov esi,offset address


    loopa: 
        mov eax,[esi]
        
        mov  cl,16
        shr  eax,cl
        mov dl,al
        mov ah,02h
        int 21h

        mov  cl,11
        shr  eax,cl
        and  al,1fh    ;check device
        mov dl,al
        mov ah,02h
        int 21h

        mov cl,8
        shr eax,cl
        and al,07h
        mov dl,al
        mov ah,02h
        int 21h
        

        inc count        ;account
    again: 
        mov al,rowx
        cmp count,al
        jz endd
        add esi,4
        loop loopa         ;loop read
    
    endd:
        mov     ax,4c00h    ;esc
        int     21h
        ret

pcitool   endp

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文