Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Change your program such that it takes as input an address-space (eg, v = 32-bit), a page-size (eg, s = 4KB), and an address (eg,

Change your program such that it takes as input an address-space (eg, v = 32-bit), a page-size (eg, s = 4KB), and an address (eg, a = 19986), and returns the page number and the offset number of the input address (eg, p = 4 and d =3602). Both v and s should be powers of 2, s < v, and v = 16 or 32 or 64, and s between 512 bytes and 1GB inclusively.

Currently it only takes one input the address (a = 19986), and outputs the page number and offset. It needs to take the address-space (eg, v = 32-bit) and the page-size (eg, s = 4KB) as inputs as well.

Program:

#include #include #include #include #include

#define PAGE_NUMBER 0XFFFFF000 #define OFFSET 0x00000FFF

int main(int argc, char *argv[]) { int pageNumber, offset; unsigned int address; address = (unsigned int)atoi(argv[1]); if(argc != 2) { printf("Error number of arguments is less that 2. "); return -1; } printf("The address %d contains: ", address); pageNumber = (address & PAGE_NUMBER) >> 12; offset = address & OFFSET; printf("Page Number = %d ", pageNumber); printf("Offset = %d ", offset); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions