Reference no: EM132165369
Basic Computer Science Assignment -
The goal of this assignment is to solve problems by programming the Simple Computer (version 3) in its machine language.
You are to write a machine-language program to solve each of the problems given below. As a reminder, the instruction set of our machine language is as follows:
Instruction
|
Operation
|
Mnemonic
|
0 0 0 a b c d e
|
M[abcde] ← R0
|
STORE
|
0 0 1 a b c d e
|
M[abcde] ← R1
|
STORE
|
0 1 0 a b c d e
|
R0 ← M[abcde]
|
LOAD
|
0 1 1 a b c d e
|
R1 ← M[abcde]
|
LOAD
|
1 0 0 a b c d e
|
Ra ← Rb opde Rc
|
ALU
|
To solve each problem, you must come up with a sequence of machine instructions that carries out the specified computation. To do this, carefully follow the steps given below.
1. Break up the problem into individual instructions that are each small enough be executed by the computer.
2. Write out the instructions of the program symbolically, as in the "Operation" column of the instruction set above.
3. Translate each symbolic instruction into binary using the templates in the "Instruction" column of the instruction set.
4. Translate each binary instruction into hexadecimal.
5. Test your program on Simple Computer 3 by entering the instructions, along with test data, into the RAM and then running the program.
Here are some notes about running machine-language programs on Simple Computer 3:
- Download the Logisim file containing the circuits for Simple Computer 3 (simple computer3.circ).
- Keep in mind that the first instruction should always be at location 0 of the RAM because the program counter will start at 0.
- To run your program, clock through the fetch-decode-execute cycle for each instruction as we have done in class.
1. To fetch the first instruction, set the "Fetch/Execute" bit to 0 and the "Clock" bit to 1. (Watch the instruction be loaded into the instruction register.)
2. To execute the first instruction, set the "Fetch/Execute" bit to 1 and the "Clock" bit to 0. (Watch the register or RAM contents be updated appropriately.)
Monitor the program counter to ensure that the instructions are being fetched/executed one-at-a-time and in order.
- To reset every RAM location and register to zero, go to Logisim's "Simulate" menu and select "Reset Simulation:' You will want to do this every time you restart a program or start a new program.
- Every time you reset the simulation, the RAM is cleared. So, if you need to restart a program, you must re-enter the instructions and the test data into RAM. You can avoid a lot of typing if you save and restore the RAM contents to and from file. Right-click on the RAM to reveal these options ("Save Image..." and "Load Image..").
To ensure that your solutions are clear and neat, either fill in or use as a template the table in this MS Word file 'v (also available as a Pages file and an OpenOffice file). To receive full credit, your solutions must include the machine-language instructions (expressed both in binary and in hex) and a symbolic summary of each instruction.
As a guide, consider this example file that gives a machine-language program that solves the problem: "Put (M[12] + M[13]) - (M[14] + M[15]) and store the result in M[11]".
To complete this assignment, solve the six problems below. In all of these problems, the numbers of the memory locations are given in decimal. However, when you work with the RAM in the simulator, you must use hexadecimal. Test your solutions extensively using the Simple Computer 3 in Logisim. DO NOT FORGET: At the start of each problem, you may not assume anything about the contents of RAM, R0, or R1.
1. Store M[3] into M[4]. (In other words, store the contents of memory location 3 into memory location 4.)
2. Store M[11] + M[12] into M[17].
3. Swap the contents of M[7] with the contents of M[6]. Do not modify any other memory locations.
4. Replace M[9] with its complement. (Recall: To complement a number, flip every bit.)
5. Store the number 1 into M[5]. Assume all arithmetic is two's complement.
6. Store the number M[16] - 1 into M[12], the number M[16] - 2 into M[13], the number M[16] - 3 into M[14], and the number M[16] - 4 into M[15]. Assume all arithmetic is two's complement.
Note - Save your solutions to a file and include your name at the top. Export to PDF format and submit.
Attachment:- Assignment Files.rar