### CSC 103: How Computers Work

Lab 3: Assembly Language

To be turned in on Moodle as part of Homework 3.

### Summary

In this lab you'll gain experience with assembly programming, which is the layer just above hardware. So all the instructions you are writing are telling these circuits what to do! You are welcome to work with a partner.

### Getting Started

To set up, open the Assembly Simulator in a new tab. Then erase all the starter code and switch the "View" to Decimal so it's easier to understand what is going on. You also might want to open the Instruction Set in a new tab.

### Program 1: A loop that can stop

On Monday we saw how to program a loop. However, we had no way of stopping that loop or controlling its behavior. For this question, write a loop that starts with 0 at register A, and goes up to 22 (the number of students in the class), and then stops. Save your program into a txt file, then use it as the basis for the next program.

### Program 2: Manipulating memory

Write a loop that stores the number 55 in the memory locations between 15 and 20, inclusive.

### Program 3: Adding a series

Now we'll see how to define variables, that might change later on for a new problem. Write a program (with a loop) that computes the sum of all the numbers from variable x to variable y, inclusive. Test your program with:

• x=1 and y=5 (result should be 15)

• x=3 and y=10 (result should be 52)

### If you have more time

• Analyze the "Hello World!" starter program and figure out all the steps.

• Choose a topic for your final project and okay it with me.

• Start to find a research paper for your final project.

### To finish up

After you're done, make sure to save each program in a txt file so that you don't lose your work. Turn this in on Moodle as part of Homework 3 by Monday before class.