# Solution for Spring 2002 CSCI 255 Homework 5

## Problem 1

Draw a block diagram of a 512M×16 RAM. The only real work here is figuring out the number of address and data pins.

Remember that, M is 220 in computer architecture. Since 512 is 29, then 512M is 229. Consequently, the number of address pins is 29. The number address pins is 16, the width of a word of memory.
Here's a solution provided by Kate Wittman. In class I drew the RAM with separate sets of input and output pins. This drawing only has one set of data pins which is a bit closer to reality because in almost all real RAM chips there is a single set of data pins that are used for both input and output.

## Problem 2

An LC-2 program, expressed in binary, appears below:

```
0010001100000000
0010010000001110
0000010000001100
0001001001100000
0000100000001000
0001001001000001
0001010010111111
0100000000000010
0001001001000001
0001001001100001
0001010010111111
0100000000000010
0011001100000001
1111000000100101
0000000000001000

```

Your assignment is to "decode" the instructions of this program into LC-2 instructions and to give some reasonable guess about the purpose of the program.

Assume that the program is loaded into memory at location x3000 and that a word of "input" data for the program is stored at location x3100. This input data is loaded from location x3100 on the first instruction of the program.

 0010001100000000 x3000 LD R1,x3100 0010010000001110 x3001 LD R2,x300E 0000010000001100 x3002 BRz x300C 0001001001100000 x3003 ADD R1,R1,#0 0000100000001000 x3004 BRn x3008 0001001001000001 x3005 ADD R1,R1,R1 0001010010111111 x3006 ADD R2,R2,-1 0100000000000010 x3007 BR x3002 0001001001000001 x3008 ADD R1,R1,R1 0001001001100001 x3009 ADD R1,R1,#1 0001010010111111 x300A ADD R2,R2,#-1 0100000000000010 x300B JMP x3002 0011001100000001 x300C ST R1,x3101 1111000000100101 x300D TRAP x21 0000000000001000 x300E .FILL #8

Although the last word in the program is the instruction BR x3008, in this example that word is being used to load the constrant value 8. Consequently, it is better to translate the word as .FILL #8.

The program performs a byte swap. The two halves of the word stored at memory location x3100 are swapped and the result is stored at memory location x3101. For example, if memory location x3100 contained x1234 when the program starts, memory location x3101 will contain x3412 when the program stops.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}