Question: 1) Program 1 will be in memory locations 00-3F. The instructions will start at 00, and the data will start at 30. You will add
1) Program 1 will be in memory locations 00-3F. The instructions will start at 00, and the data will start at 30. You will add input values stored in locations 30, 31, and 32 (since this is your input, you will need to manually enter test values), and put the sum in memory cell 33 (which is your output). Assume all values are numbers are in two's complement. Use as few registers as possible. 2) Program 2 will be in memory locations 40-7F. The instructions will start at 40, and the data will start at 70. Your input will be in memory location 70. Without using jmpLE, you will test if the input is positive (0 or greater) or negative (less than zero), treating the input as a signed integer (in two's complement). If the input is positive, you will signal this by copying the value of the input into memory cell 71. If the input is negative, you will signal this by putting the value "-1" in memory cell 71. (Hint: when not using jmpLE, consider how you can tell a positive number from a negative one in two's complement, then look for an operation which will allow you to focus on only that one thing. And you will need to use jmpEQ (jump if equal).) 3) Program 3 will be in memory locations 80-BF. The instructions will start at 80, and the data will start at B0. You will begin with input values in B0 and B1. Assume these are numbers in two's complement. Find the difference between these two numbers (i.e., the larger one minus the smaller one), and write the result in B2. Note that there is no subtraction operation - you will have to figure out how to perform the subtraction. (Hint: jmpLE, though not part of the instruction set from the textbook, is both allowed and useful.) When your programs give output, make sure you send it to the right place, and be careful not to have any program access or change the memory space of your other programs. Scoring: 3 points for one working program, 7 points for 2, 10 points for 3. There will be partial credit as well. Extra Credit: For 2 additional points (which can bring your total up to 12): Write a 4th program in memory locations C0-FF. The instructions will start at C0, and the data will start at F0. You will find the average (using integer division, so you can drop any fraction) of a group of positive integers. The input values will start at F0 and fill consecutive cells (F1, F2, etc). You may assume these numbers are positive integers, and small enough so that their sum does not cause overflow. You will know the input has ended when you reach a value of "00". Take these numbers and find the average of them, ignoring any fraction. Put the result in FF. Hint: you will need to use loops, indirect load, and an accumulator for this program. You should be able to fit this in 3 lines of the SimpSim, but if you need to allocate less space to your earlier programs you may do so. Just remember to fix the addresses if/when you do.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
