Gettysburg College

CS 221
Computer Organization and Assembly Language Programming

Spring 2023

Assignment 8

Due: Thu, Mar 30, by 11:59pm

Readings

Description

This assignment will focus on the following tasks: Build the PC circuit described in Project 3:

N2T: Project 3

Chapters 3 provides the contract for each chip, i.e. description of its behavior, names and number inputs, names and state of outputs. The API is available here:

The Hack Chipset

Assembly Language Programming

vvv
vvv Scroll to the bottom. Consider starting with the Assembly section.
vvv

Design in Logisim

Note the following requirements: Here are additional specific requirements:

Design in HDL

Note the following additional requirements:

Here are additional specific requirements:

Modify and test the respective .hdl file given by the authors:

Assembly Language Programming

Note the following:

Arrays as Parameters

Modify the example from class sum_array.asm (linked at the top), so that it can be used as a function of two parameters that returns the sum of the first n numbers:

def sum_array( numbers, n ):
    ...
    ...
    return the-sum-of-first-n-numbers

At the top declare two different arrays of different lengths and run the function as follows:

Fibonacci Numbers

In file fibonacci.asm write a recursive function that computes the n-th Fibonacci number:

def fib( n ):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return fib(n-1) + fib(n-2)
At the top run the function 4 times times one after the other:

Recursive Binary Search

In file binarySearch.asm write a recursive function that search for a value in an array using binary search. Recall that binary search requires a sorted array and works as follows:
def binarySearch( i, j, numbers, value ):
    if i > j:
        return 0, -1

    m = (i+j) / 2
    if numbers[m] == value:
        return 1, m
    elif numbers[m] > value:
        return binarySearch( i, m-1, numbers, value )
    else:
        return binarySearch( m+1, j, numbers, value )

The function takes 4 parameters in this order:

The function returns two numbers:

Note that ARM does not have instruction to divide, but division by 2 can be accomplished via right shift:

LSR DestReg, RegToShift, NumShifts

At the top declare two different arrays of different lengths and run the function several times:

Note the following:


What to turn in

Zip folder 05/ in file named 05.zip and upload it to the Moodle dropbox.