Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please place comments where indicated in the Java code below. Paste complete code when done and make sure it runs. Code: /** * Address.java *

Please place comments where indicated in the Java code below. Paste complete code when done and make sure it runs.

Code:

/**

* Address.java

*

* Usage:

* java Address

*

* For the given page size and virtual address,

* this program reports the page number and offset.

*/

public class Address

{

public static final int ADDRESS_SIZE = 32;

public static void main(String[] args) {

if (args.length != 2) {

System.err.println("Usage: java Address

");

System.exit(0);

}

/* Comment Here */

int pageSize = Integer.parseInt(args[0].trim());

int address = Integer.parseInt(args[1].trim());

int pageBits = 0;

int pageMask = 0;

int offsetMask = 0;

/* Comment Here */

switch (pageSize) {

case 1024:

pageBits = 10;

offsetMask = 0x000003ff;

pageMask = 0xfffffc00;

break;

case 2048:

pageBits = 11;

offsetMask = 0x000007ff;

pageMask = 0xfffff800;

break;

case 4096:

pageBits = 12;

offsetMask = 0x00000fff;

pageMask = 0xfffff000;

break;

case 8192:

pageBits = 13;

offsetMask = 0x00001fff;

pageMask = 0xffffe000;

break;

case 16384:

pageBits = 14;

offsetMask = 0x00003fff;

pageMask = 0xffffcfff;

break;

}

int pageNumber = (address & pageMask) >> pageBits;

int offset = (address & offsetMask);

/* Comment Here */

System.out.println("For address " + address + " page number = " + pageNumber + " offset = " + offset);

}

}

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

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions