Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

CPE 301

March 5, 2013
Design Assignment #1

a. Store 20 numbers starting at RAM_START (0x0100).

Code:

The code stores twenty numbers in increasing order.

Simulation:














b, c. Sum of odd numbers stored in R20:21. Sum of even numbers stored in R23:24

Code:



The code adds all odd numbers and stores them in R20:21, while also adding all even
numbers and storing the result in R23:24.

Simulation:



Odd sum is: 0x27 + 0x29 + + 0x39 = 39 + 41 + + 57 = 480 = 0x1e0
Even sum is: 0x28 + 0x 2a + + 3a = 40 +42 + + 58 = 490 = 0xea

This shows that the simulation produces the correct sums.











f. Running sum

Code:




The first part of the code simply adds the first five numbers. The second part uses two
pointers to subtract the oldest value and add the newest value. When either pointer hits
the end the list, they are reset and start from the beginning of the list. This code will loop
forever, and keep subtracting the oldest value in the sum and adding the next value in
the list. The sum is stored in R19:18.




Simulation of first five numbers:


First five numbers are: 0x27, 0x28, 0x29, 0x2a, 0x2b. Their sum is 205 or 0xcd.

Simulation of next five:



Next five numbers are: 0x28, 0x29, 0x2a, 0x2b, 0x2c. Their sum is 210 or 0xd2.
























g. Generate a non-subsequent sequence:

Code:


This code generates a pseudo-random sequence by using the rotate, and swap
instructions.


Simulation:

You might also like