Question
The original program that needs to be modified: #include #include #include #define PAGE_NUMBER 0xFFFFF000 #define OFFSET 0x00000FFF int main(int argc, char *argv[]) { int pageNumber,
The original program that needs to be modified:
#include
#include
#include
#define PAGE_NUMBER 0xFFFFF000
#define OFFSET 0x00000FFF
int main(int argc, char *argv[]) {
int pageNumber, offset;
unsigned int entry;
entry = (unsigned int)atoi(argv[1]);
if (argc != 2) {
fprintf(stderr, "Please enter: ./assign4_1 followed by the virtual address");
return -1;
}
printf("The address %d contains: ", entry);
//Mask the page number
pageNumber = (entry & PAGE_NUMBER) >> 12;
offset = entry & OFFSET;
printf("page number = %d ", pageNumber);
printf("offset = %d ", offset);
return 0;
}
The requirements for the problem:
Change your program, Program-1, 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, sStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started