Difference between revisions of "CSC103 Homework3 Solutions, 2012"
(Created page with "--~~~~ ---- =Wiki Page= General Comments: * You had to answer the questions from the lab handout * You had to use the different wiki features listed in the homework * You had t...") |
(→Assembly Language) |
||
Line 18: | Line 18: | ||
; a specific series of integers: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19. | ; a specific series of integers: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19. | ||
; | ; | ||
− | start: lod-c 1 | + | start: lod-c 1 |
sto var1 | sto var1 | ||
add-c 2 | add-c 2 | ||
Line 41: | Line 41: | ||
hlt | hlt | ||
@30 | @30 | ||
− | var1: | + | var1: data |
− | var2: | + | var2: data |
− | var3: | + | var3: data |
− | var4: | + | var4: data |
− | var5: | + | var5: data |
− | var6: | + | var6: data |
− | var7: | + | var7: data |
− | var8: | + | var8: data |
− | var9: | + | var9: data |
var10: data | var10: data | ||
Revision as of 14:11, 28 February 2012
--D. Thiebaut 14:11, 28 February 2012 (EST)
Wiki Page
General Comments:
- You had to answer the questions from the lab handout
- You had to use the different wiki features listed in the homework
- You had to write a paragraph for each main component found.
- If you closed up the PC at the end of the lab, you got extra credits in the form of 1/3 point that was added to the final grade (pink grade).
Assembly Language
- There were several ways to write the program. Here's one below that uses different instructions.
- Importantly, you have to make sure that the address you specify for the data with the @ symbol is above the address of the last instruction, which is a hlt instruction. If you do not, then your program overwrites the instructions at the end of your program and you have a program with a major bug on your hands!
; Assembly language program that initializes 10 variables with
; a specific series of integers: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19.
;
start: lod-c 1
sto var1
add-c 2
sto var2
lod-c 5
sto var3
add-c 2
sto var4
inc
inc
sto var5
add-c 2
sto var6
add-c 2
sto var7
add-c 2
sto var8
add-c 2
sto var9
add-c 2
sto var10
hlt
@30
var1: data
var2: data
var3: data
var4: data
var5: data
var6: data
var7: data
var8: data
var9: data
var10: data
Timing Analysis
- If the processor runs at 3 GHz, it executes 3,000,000,000 cycles in 1 second.
- The processor executes 1 instruction each cycle
- The program above contains 22 instructions
- It will take the processor 22 cycles to execute our program
- In terms of time, this will be 22 * 1 sec / 3,000,000,000 = 22/3 10^-9 = 7 nanoseconds, approximately, or 7 billionth of a second.