Fall 2009
Revisions:
None yet.
Material covered:
Chapter 1: Computer Abstractions and Technology
Coverage: Ch 1.1-1.6, SPEC CPU benchmark (pp. 48-50), Ch 1.8-1.9
Chapter 2: Instructions: Language of the Computer
Coverage: Ch 2.1-2.3; 2.6-2.9
Alignment & Endian-ness
Programming assignments: 0, 1, 2
Homework questions due: Wednesday, 7 October 2009 [15 pts]:
Homework is due at the start of class on the due date. Late homeworks will not be accepted. Homeworks must be type-written, and not hand-written. Keep a copy of your homework, and bring this with you the day of the quiz/exam review (i.e., the day the homework is due). This should help you in the review session.
For the homework, do the following 15 of the study questions:
Q #1 [1 pt]
Q #7 [1 pt]
Q #8 [1 pt]
Q #9 [1 pt]
Q #10 [1 pt]
Q #11 [1 pt]
Q #12 [1 pt]
Q #16 [1 pt]
Q #22 [1 pt]
Q #25 [1 pt]
Q #27 [1 pt]
Q #28 [1 pt]
Q #29 [1 pt]
Q #32 [1 pt]
Q #35 [1 pt]
.data
bytes: .asciiz "abc123\n"
.text
main:
# This code will successively put the
# bytes of "bytes" into the register
# $s0, from left to right, stopping
# when we hit "\n" (10).
# put address of our string into $t0
la $t0, bytes
li $t1, 10
Next:
lb $s0, 0($t0)
beq $s0, $t1, End
# increment address ($t0) to reference
# next character
addi $t0, $t0, 1 # $t0=$t0+1
j Next
End:
a = 10;
c = 0;
e = a + 20;
a = a + c;
d = a – e;
a = 10;
b = a * 16;
li $t1, 0x1234
andi $t0, $t1, 0x00ff
li $t1, 0x0034
ori $t0, $t1, 0x1200
if (a == b) {
c = 10
} else {
c = 20;
}
a = 0;
do {
a++
} while (a < 10);
int func2(int b) {
return b*3;
}
int func1(int a) {
return func2(a+1);
}
// Also code a call to func1: func1(5)
struct: double 0.0 # struct.d
float 1.0 # struct.f
word 15 # struct.i
byte 'x' # struct.c
What is the total size of the structure?
What are the displacements (starting addresses) for each of its members?