Page 1 of 1

error in paging page ?

Posted: Wed Oct 12, 2016 6:38 am
by stdcall
In http://wiki.osdev.org/Paging#Manipulation

I think the following line is wrong here:

Code: Select all

    unsigned long * pt = ((unsigned long *)0xFFC00000) + (0x400 * pdindex);
I think it needs to be

Code: Select all

    unsigned long * pt = ((unsigned long *)0xFFC00000) + (0x1000 * pdindex);
Am I wrong ?

Re: error in paging page ?

Posted: Wed Oct 12, 2016 6:51 am
by Techel
When adding to pointers the offset is multiplied by the pointee's size:

Code: Select all

int *p = ...
p += 5; //adds 5*sizeof(int)

short *p = ...
p += 3; //add 3*sizeof(short)

Re: error in paging page ?

Posted: Wed Oct 12, 2016 7:00 am
by stdcall
You're right I missed a parenthesis. thought the the casting to unsigned long * was after the multiplication.