# Midterm 1 -- Open book section

23 February, 1995

The entire exam is to be turned in at 5:45 PM. Work the closed
book section first and turn it in before you consult your books and
notes to work on the open book section.

## Problem 1 (6 points)

Translate the following expression into RPN:

## Problem 2 (12 points)

How would you translate the following C statements into the
assembly language of a RISC- like computer:

`C := A * B ;`
`F := C + D + E ;`

You should assume that the RISC-like computer has 32 registers,
memory-to-register load/store instructions, and three-register
arithmetic instructions.

## Problem 3 (6 points)

Show the data dependencies in the following sequence of
operations. Assume that the first two registers are the operands
and the last register is the destination in which the operation
result is stored.

`add R1,R2,R3`
`add R4,R4,R5`
`add R3,R5,R5`
`add R3,R4,R6`

## Problem 4 (6 points)

How could an instruction that increments a register and then
branches if the register is zero be used to efficiently execute
FORTRAN DO loops?

## Problem 5 (6 points)

The Alpha AXP processor has an instruction `s8addl` such
that

sets *Rc* equal to *Ra**8+*Rb*. Where would an
instruction like this be useful?

## Problem 6 (6 points)

How can you set bits three to seven of a 32-bit word to zero
using standard logical operators?

## Problem 7 (6 points)

A computer has 32-bit instructions and 14-bit addresses. If
there are 14 two-address instructions, how many one-address
instructions can be formulated?

## Problem 8 (12 points)

Describe how a loop like the one below can be efficiently
executed on a vector processor like a Cray.

for (i=0; i<698; ++i)
{
B[i] = A[i] + A[i+1] ;
A[i] = s + A[i] ;
}

Back to the Handout index

Return to Dean Brock's
home page

Return to
the UNCA Computer Science
home page