1 year ago
#361829
LYJ
store pci address in memory and display
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
assembly
x86
pci
0 Answers
Your Answer