Can someone help with this code? I have no idea on how to even begin :( It can b
ID: 3576357 • Letter: C
Question
Can someone help with this code? I have no idea on how to even begin :(
It can be either in C++ or Python. Thanks in advance, I really apreciate it!
Explanation / Answer
A virtual is composed of page number and offset.
Since the page size is 4KB, the page size is represent using 16bit.(2^16=4KB)
So, the first 16 bits in the virtual address represents page number, and remaining 16 bits represents
the offset within that page.
Please see below python program to get the page number , and offset .
###############
import sys
print (sys.argv)
virtualAddress= int (sys.argv[1])
pagenumber= int ( virtualAddress & 0xFFFF0000 ) >> 16;
Offset = ( virtualAddress & 0xFFFF);
print "Page number = ", pagenumber
print "Offset", Offset
###############
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.