views:

24

answers:

1

Let's say we have 1kb pages (2^10). The address is 512. To find the number of pages we do:

512/1024 = 0.5 (therefore it's on page 1)

To find the offset we do (address - (page*page_size)):

512 - (1*1024) = -512

A negative offset is not possible, is it?

+2  A: 

Your address is in page 0, not page 1. You are correct that a negative offset is not possible.

Carl Norum
Doh, I just realized a moment ago. I feel silly. So the page is 0 and offset is 512?
Google
@Google, yes, that's correct.
Carl Norum
Thanks a lot, I feel silly!
Google