Difference between revisions of "CSC103 2011 Homework 3"
(→Problem #2) |
|||
Line 19: | Line 19: | ||
* 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 Memory Location 20 (or other convenient location). Your program should stop when it has finished adding the number 10 to Memory Location 20. | * 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 Memory Location 20 (or other convenient location). Your program should stop when it has finished adding the number 10 to Memory Location 20. | ||
+ | <br /> | ||
* You are free to write the program in one of two different ways: | * You are free to write the program in one of two different ways: | ||
+ | <br /> | ||
*#The first option is to store the ten numbers 1, 2, 3, ... 10 in 10 memory locations, and add them up to compute the sum, or | *#The first option is to store the ten numbers 1, 2, 3, ... 10 in 10 memory locations, and add them up to compute the sum, or | ||
+ | <br /> | ||
*# write a loop that adds the 10 numbers by computing them and storing the sum in Memory Location 20. | *# write a loop that adds the 10 numbers by computing them and storing the sum in Memory Location 20. | ||
+ | <br /> | ||
* Your program '''should''' stop automatically when it is done. | * Your program '''should''' stop automatically when it is done. | ||
+ | <br /> | ||
Revision as of 22:01, 14 February 2011
This homework is due on Monday, Feb. 21st, 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.
Contents
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, transcribe it on a piece of paper which you will submit as the solution to this homework.
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 Memory Location 20 (or other convenient location). Your program should stop when it has finished adding the number 10 to Memory Location 20.
- You are free to write the program in one of two different ways:
- The first option is to store the ten numbers 1, 2, 3, ... 10 in 10 memory locations, and add them up to compute the sum, or
- write a loop that adds the 10 numbers by computing them and storing the sum in Memory Location 20.
- Your program should stop automatically when it is done.
- As with Problem 1, copy your solution to a piece of paper that you will submit on the 21st, at 9:00 a.m.