It always prints a blank space and then a 2 dotted U.
If I increase the amount of characters I print out it just prints garbage.
Can anybody see the problem here with the int 10.
I set es:bp -> to vendor.
As a test I put vendor = 'JB'
Thanks for any help .
Does it have to do with bits 32 or bits 16
Because I never used int 10 in a 32 bit program
Also I am just running it under ms dos on windows xp.
Code: Select all
[BITS 32]
;compiled with nasm -f obj PCIdev.asm
; linked with tlink PCIdev.obj
segment data
BUS_NUMBER db 0 ; bus number 1 to 256 are valid values
DEVICE_NUMBER db 29 ;device number 1 - 32 are vaild values
FUNCTION_NUMBER db 7 ; function number 1-8 are vaild values
REGISTER_NUMBER db 0 ; register number 1-64 are vaild values
vendor db 'JB' ; just test values print should print JB but it doesn't it prints a blank and a weird 2 dot U ascii 154
segment code
..start:
jmp main
;PCI_FUNC is a function that returns a word from the pci configuration space
;using data in BUS_NUMBER , DEVICE_NUMBER , FUNCTION_NUMBER , REGISTER_NUMBER
;output is in ax
;registers effected are eax
;Basically the function just send a 32 bit number to the configuration address and reads a word from the data address of the pci
PCI_FUNC:
push edx ; saves your data that was previously in edx before using edx
mov eax , 0 ; initalize the register to zero
mov edx , 0 ; initalize the register to zero
mov eax , 1 ; mov 00000001 into eax
shl eax , 31 ; shift the 1 to the top most bit 10000000
mov edx , BUS_NUMBER ; mov the bus number byte into edx
shl edx , 16 ; move the bus number to bits 23 - 16
or eax , edx ; put bus number in eax
xor edx , edx ; zero out edx
mov edx , DEVICE_NUMBER ; mov device number into edx
shl edx , 11 ; shift the device number to bits 15-11
or eax , edx ; put device number in eax
xor edx , edx ; zero out edx
mov edx , FUNCTION_NUMBER ; move the function number into edx
shl edx , 8 ; shift function number to bits 10 - 8
or eax , edx ; put function number in eax
xor edx , edx ; zero out edx
mov edx , REGISTER_NUMBER ; move register number into edx
shl edx , 2 ; shift register number to bits 7-2
or eax , edx ; put register number in eax
xor edx , edx ; zero out edx for the hell of it to clean it out
mov dx , 0xCF8 ; move the configuration address for the pci into dx
out dx , eax ; send the data in eax to the configuration address port
mov dx , 0xCFC ; move the configuration data address into dx
in ax , dx ; read a word from the configuration data address 0xCF8
pop edx ; returns your previously saved edx value back to edx
ret
PRINT_PCI: ;this function prints the 2 bytes of the vendor id
mov ax , ds
mov es , ax ; make sure es points to the same segment as data segment
mov cx , 2 ; output 2 bytes vendor is a word
mov bx , 000Fh ; make text color attrubites ...etc white
mov ax , 1300h ; prints string bios function
mov dx , 0000h ; cursor row / column zero
mov bp , vendor ; pointer to the string to output es:bp --> vendor
int 10h
ret
main:
;this function call was commented out because I am trying to get the print function to work
;call PCI_FUNC
;mov [vendor] , ax ; mov the result of the function into varible vendor
call PRINT_PCI
loopforever:
jmp loopforever
segment stack stack
resb 256 ; reserve 256 bytes for the stack.
stacktop: