CSC103 2011 Homework 3
This homework is due on Monday, Feb. 21st, Tuesday, Feb. 22nd, at 9:00 a.m. You should make sure that you have gone through all the steps of Lab #3 as preparation for this homework.
You may find the information in the following two documents very useful for working on this homework:
Problem #1
- Use the Processor/Memory simulator and write a program that starts with 4 numbers stored in memory Locations 14, 15, 16, 17, and that stores the sum of all 4 in memory Location 18.
- When you program works correctly, copy it to a text file of your choice. Save the file for right now.
- Use labels in your program for instructions and for data (as described in xComputer Lab 2).
- Try to be efficient and attempt to use as few instructions as possible.
- Format your program neatly, so that all the labels start at the left margin, all the instructions are one above the other, all the comments (if any) one on top of the other.
Problem #2
- Write another program that computes the sum of the integers 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10, and stores the sum in a memory location labeled as sum. Your program should stop when it has finished adding the number 10 to the location sum.
- Make your program store the ten numbers 1, 2, 3, ... 10 in 10 different memory locations, and add them up to compute the sum
- Your program should stop when it is done.
- As with Problem 1, copy your solution program at the end of the file you created for Problem 1.
Problem #3
- Same as Problem #2, but without storing the ten numbers in memory. The program should generate all the numbers required in the accumulator, and use only 1 memory location to store data.
- As with Problem #2, copy your solution at the end of the same file containing the other answers.
Problem #4
- Same as Problem #3, but your program this time will compute the sum of only the even numbers between 1 and 10. In other words, make your program compute the sum of 2 plus 4, plus 6, plus 8, plus 10 using a loop.
- As with Problem #3, copy your solution at the end of the same file containing the other answers.
Recommendations
- Programming is the art of writing complex instructions that a machine will have to execute. It can be very tedious to read computer code. The neater you are in writing your code, the more comments you add to your code, the easier it is to read and understand.
- Make sure you write your code as neatly as possible!
Submission
- Email the file containing the solution to all 3 problems as an email message (no attachment, please!), and address it o 103b@cs.smith.edu. Make sure your name is at the top of the text of your message.