Project Assignment 2

CSC255 - Information Structures & Representations

Due: 5/30/2001

Given the hypothetical machine described in Appendix C of our text, develop the programs described below. The final result should be stored at memory address a4 in all cases.

You should turn in four separate programs, each annotated with descriptive comments on each line of your program as in this supplied sample program. Also, a trace report should be included for each program. See this sample trace for the program above.

  1. Write a set of instructions to add the numbers at the following memory locations. To make things simple, assume integer addition of positive values. Use the following example to trace your program:

    Memory address a0: 5610
    Memory address a2: 6410

  2. Write a set of instructions to subtract the numbers at the following memory locations. To make things simple, assume integer subtraction of positive values with the larger value always in the first memory location. Use the following example to trace your program:

    Memory address a0: 5610
    Memory address a2: 1610

    Note: Remember that you must first convert the value being subtracted to it's two's complement representation as the initial step. Notice that since you can assume that you will always be subtracting a smaller number from a larger number then the result will be positive.

  3. Write a set of instructions to multiply the numbers at the following memory locations. To make things simple, assume integer multiplication of positive values. Use the following example to trace your program:

    Memory address a0: 1010
    Memory address a2:   310

    Note: There is no multiply instruction in the instruction set of our CPU and so you must implement multiplication using the technique of repeated addition.

    Hint: Your program must repeat an addition. Use the sample program as a basis for your program.

  4. Write a set of instructions to divide the numbers at the following memory locations. To make things simple, assume that the larger number will always be placed in the first memory location. Also, assume integer division of positive values. That is, your result will be positive and will not contain fractional values. Use the following example to trace your program:

    Memory address a0: 1210
    Memory address a2:   410

    Note: There is no divide instruction in the instruction set of our CPU and so you must implement multiplication using the technique of repeated subtraction.

    Hint: Your program must repeat a subtraction. Use the sample program as a basis for your program.

As an extra credit exercise attempt executing programs #3 and #4 above using the PUP simulator. Note that this simulator has a very different instruction set than the hypothetical machine above.