Learning Goal: I’m working on a java project and need support to help me learn.
In this series of programming assignments, you would go through the step-by-step design process of a simple computer (along with its Instruction Set Architecture) and develop a software emulator for this machine. You would then complete the series by developing an assembler that can assemble a simple program written in using the instruction set to machine code, which is executed by the emulator. For the first assignment, your job is set up the basis for internal data representation in the CPU, namely the bits and the word. While Java provides bit-manipulation capabilities using bitwise operators (&, |) and bit-shifts (<<,>>), those bit manipulations are to be done within some form of an integer (byte, short, int or long). However, Java’s lack of support for unsigned integer type comes as an impediment to having full control for our own algorithms for bit-level arithmetic implemented. The next best option is to use the “boolean” data type, where we can use the “true” value for a “1” and “false” value for a “0”. (Internally, Java uses a whole byte for storing these two possible values, because a byte is the smallest storage allocation possible for storing a variable. One can also use a byte-sized integer, which is going to take the same space, but the handling the exception when any value other than 0 or 1 is set becomes the programmer’s burden.) A single bit, by itself, is not very useful. In order to represent values and addresses, we need multiple bits. For the machine that we are emulating, we will be using a 32-bit value for both addresses and values. A word is an indexed collection of bits (like an array), originally fitting the size that the machine “natively” works on. Along the history of computing, a word became 16 bits. A 32-bit collection of bits was then named as “long-word” (Similarly, 64-bit is “quad-word”). The BitSet class in java.util package, designed for representing a set using a bit-vector, can be repurposed for our need. It is much more space-efficient in that it uses only one bit internally for each bit/boolean value stored in an array of long (64-bit) integers. To satisfy our need for 32 bit/boolean values, just a single-element array suffices as that single long integer can pack up to a maximum of 64 bit/boolean values. Moreover, most of the operations we need to perform on our machine’s long-word are easily implemented using the built-in methods of the BitSet class, often using simple wrappers. For our 32-bit machine word, the LongWord class implementation must follow these specifications: 1. The LongWord class must be a new class that does not inherit from (i.e., extend) any other class (i.e., it implicitly extends only the Java Object class). 2. A LongWord object must have a bit-vector (indexed collection of bits) as part of its data field, to be implemented using the Java BitSet class, storing the 32 bits of the long-word. Treat the 0th bit of the bit-vector as the least significant and the 31st bit as the most significant bits. For the sake of preserving consistency across the class, you may not use any other storage mechanism. Do not forget to import java.util.BitSet in your source code. 3. You must create the API for your class by implementing the following methods: a) At creation, every bit of a LongWord object must be initialized to “0”. Follow the BitSet class documentation to figure out anything you need to do in the constructor to ensure this. b) Override default toString method of Java objects, also being careful not to make use of the default toString method of the BitSet data field, which only lists the bit-indexes (for which the boolean/bit value is true/1) in the set notation. Instead, the printable string form should have all the 32 bits listed as 0/1 with the most significant bit in the leftmost position and the least significant bit placed at the rightmost. You may like to group them by 4 or 8 bits with a space in between. This should be followed by a tab (‘\t’) as delimiter and the equivalent 8 hex digits for the binary pattern prefixed by 0x, indicating that what follows are hex digits. A typical string representation may look like the following: 1010 1010 1010 1010 1010 1010 1010 1010 0xaaaaaaaa You must use @Override annotation to make the compiler enforce overriding of toString. @Override String toString(); // returns a string of 0’s and 1’s // followed by equivalent hex notation c) Implement the
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more