﻿ Homework

Due Mar 4

## Microprograms

You can test your microprograms using the simulator by entering your programs in binary in the microprogram editor. Before running your programs, you'll need to edit the memory locations that you access in order to check the results generated by your programs.

### Problem 1

Write a microprogram that finds the sum of the word values stored at word addresses 0, 1, 2, and 3 and stores the result in word address 4. Don't forget that the values stored in MAR are word addresses. This program should have a sequential structure. Don't try to implement a loop. Thinking of memory as an array of integers, this problem becomes:

mem[4] = mem[0] + mem[1] + mem[2] + mem[3]

### Problem 2

The values stored in memory locations 0, 1, and 2 represent memory addresses. That is, the value stored in mem[0] is the address at which an integer value is stored, the value stored in mem[1] is the address at which an integer value is stored, and the value stored in mem[2] is the address at which an integer value is stored. Write a microprogram that adds the values stored in the first two addresses and stores the sum in the third address. Symbolically,

mem[ mem[2] ] = mem[ mem[0] ] + mem[ mem[1] ]