-
It looks like you maybe don't need to, if this is working. (But I was envisioning reading in two bytes and only keeping the low one, or something similar; surely there's an index register that you would increment if you needed to read two consecutive bytes with inb, or has MMIX messed with my head way too much?)
-
EDIT: I take back what I thought. I agree with you. I think that if I access it the way you suggested that would be right. Because I looked at device manager and saw the IO range for the bar I am r/w from is 9800 - 9807, so 4 bits * 8 = 32 bits. So if this is true then to r/w from bits 23:16 I should write to 9806 first four bits and 9805 last four bits to r/w bits 23:16? So I would just do:
outb(0x9800+0x05, 0x3f&0xff); //write last four bits
outb(0x9800+0x06,0x3f>>4); //write top 4 bits
and it would be the relative same for inb:
i=inb(0x9800+0x05); //write last four bits
j=inb(0x9800+0x06); //write top 4 bits
printf("9805: 0x%x", i&0xff); //read last four bits
printf("9806: 0x%x",j>>4); //read top four bits
something like that?
-
Erm. Usually each address has eight bits in it, not four? That is, addresses go by bytes, not nybbles. So 0x9805 would have eight bits in it, and those eight bits would be 23..16 of the whole 32-bit thing.
(Remember, you said 9800 to 9804 was 32 bits; 32 divided by 4 is 8.)
-
How would those addresses work out then, would it work like so:
9800+0x00 to 9800+0x03
9800 - 31:24
9801 - 23:16
9802 - 15:8
9803 - 7:0
9800+0x04 to 9800+0x07
9804 - 31:24
9805 - 23:16
9806 - 15:8
9807 - 7:0
thanks
-
Right. (There's nothing special about PCI here, except the numbers being really low -- the same thing would be true about 32-bit integers on the stack:
Code:
int main(void) {
int foo = 0x64656d6f;
char *bar = &foo;
for (int i = 0; i < 4; i++) {
printf("Address %p is %x: %c\n", bar+i, bar[i], bar[i]);
}
return 0;
}
generally speaking, each address represents a byte.)
-
to pick up on our discussion about bit placement and ports. I have learned that in the x86 machine the smallest bits associate with the smallest ports, so what we have is actually the opposite of what we should have, so:
9800 = 7:0
9801 = 15:8
etc...