Intro to Computer Engineering

Assignment 10 - Assembly Puzzles Part 3

Click here to access the Canvas page with the repository for this assignment.

========

Overview

In this assignment you’re tasked with creating more functions using assembly language. There are two big differences between this assignment and the last:

As before, you will likely want to keep the AVR Assembly Reference handy as well as the rules for register usage. Make sure you are using registers appropriately - we will be checking for this when you demo. Some of the functions you have to complete are both called and call another function — they need to follow both the caller-saved and the callee-saved conventions!!! Use the stack!

========

Goals

The goal of this assignment is to implement basic functions in assembly language. The functions chosen are examples that may actually be implemented in assembly rather than a higher level language.

The main concepts are:

========

The Assignment

In your repository you will find an assignment10Demo Arduino project. This project contains the prototypes for the functions we are asking you to write as well as code to test your work.

The Assembly language functions may be easier to write if you have already tested the logic using C. There are three C-functions you’ll need to complete in assignment10Demo.ino:

There are five functions to complete entirely in assembly language:

========

Getting Started

Assembly language can be challenging. The provided files include several test cases to help you with your work. Here’s the approach we suggest:

  1. assignment10Demo.ino includes a lot of code to help you with testing. The setup() includes calls to all test cases.

  2. Complete the global functions first, and make sure they pass the tests. You will need to create a global variable in assignment10.S before you can use it in your assembly functions.

  3. For the remaining functions, it is probably best to start with the C-code versions of the functions. This will give you an idea of how to manipulate the pointers accordingly when you go to write the assembly functions.

  4. Write and test the assembly language version of finding the length of a string: cStringLength in assignment10.S.

  5. Write and test the assembly language version of sumArrays. Note that you have three array pointers here: two arrays to be added and one array for the result. You need to be careful with how you manipulate these pointers - make sure you don’t lose any of the pointers! Conveniently, there are also 3 addressing registers (X, Y, Z).

  6. Write and test the assembly language version of cDot. You will need to do multiplication for this problem, so make sure you are using the mul instruction appropriately, as you did on the previous assignment.

========

A Word on Multiplication

It is in your best interest to read up on the AVR Multiplication Instruction before attempting to complete the cDot function.

The output of the multiplication instruction will be placed in r0 and r1. Note, however, that r1 is a special register that is expected to contain zero. What this means is that if you use a multiplication instruction, you must read the value out of r1 and set it back to zero as soon as possible.

========

Checkout

  1. Commit your code and verify in your web browser that is is all there.
  2. Check out with a TA.

The rubric

Generated at 2024-04-06 20:30:52 +0000.
Page written by Doug Shook & Roger Chamberlain.