Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java: Briefly explain the code in each area with /*comment*/ above it ** * Address.java * * Usage: * java Address * * For the

Java: Briefly explain the code in each area with /*comment*/ above it

** * 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_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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions

Question

11.13.

Answered: 1 week ago