Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Update the 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.

Sample input:

./a.out 32 4 19986

Sample output:

The address 19986 contains: Page number = 4 Offset = 3602

Currently it only takes one input the address (a = 19986), and outputs the page number and offset. It needs to have the input/output like the sample above.

Current input:

./a.out 19986

Current output:

The address 19986 contains: Page number = 4 Offset = 3602

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 in arguments "); 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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

=+ Is the source or sponsor of the information indicated?

Answered: 1 week ago

Question

1. Prepare a flowchart of Dr. Mahalees service encounters.

Answered: 1 week ago