Docsity

Test 1 - Spring 2005 | Computer Architecture | ECE 484, Exams of Computer Architecture and Organization

Toggle sidebar
bg1
Test 1
ECE 484/584 -- Spring 2005
Chapters 1 - 4.5
Name: ___________________________ Student Number: ______________________
1) Given 4 bits to represent data in memory, what is the range of signed integers that can be represented if
two’s complement representation is used? (5 points) Also, what is the binary representation for -9? (5
points)
range: (-8) – 7
-9 can’t be represented using only 4 bits and using 2’s complement representation
2) Given 4 bits to represent data in memory, what is the range of signed integers that can be represented if
sign-and-magnitude representation is used? (5 points) Also, what is the binary representation for -1? (5
points)
range: (-7) – 7
-1 = 1001
3) Give the 8-bit representation of the numbers -10 and 100 in sign-and-magnitude and two’s complement
representations and show how each representation is sign-extended to 16 bits. (10 points)
sign-and-magnitude (-10): 1000 1010 sign extended: 1000 0000 0000 1010
two’s complement (-10): 1111 0110 sign extended: 1111 1111 1111 0110
sign-and-magnitude (100):0110 0100 sign extended: 0000 0000 0110 0100
two’s complement (100): 0110 0100 sign extended: 0000 0000 0110 0100
4) Given that a program executes on computer A in 7 seconds. This particular program performs both
floating point and integer operations. The floating point operations make up 40% of the total execution
time of the program on machine A. Machine B incorporates new floating point hardware that can improve
the time for floating point operations. By what amount does machine B need to improve the floating point
operations of machine A in order to achieve a new execution time of 5 seconds? (10 points)
5.3
8.0
8.2
8.2
8.0
sec2.4
8.2
5
__
.____
___
speedup
speedup
Speedup
unaffectedtimeexe
Speedup
impbyaffectedtimeexecution
timprovemenaftertimeexecution
5) Draw a 1-bit ALU capable of performing or supporting the instructions AND, OR, ADD, SUB, SLT.
Show all data and control lines. (10 points) Then, draw a 4-bit ALU using an abstraction for the 1-bit
pf3
pf4
pf5

Partial preview of the text

Download Test 1 - Spring 2005 | Computer Architecture | ECE 484 and more Exams Computer Architecture and Organization in PDF only on Docsity!

Test 1

ECE 484/584 -- Spring 2005

Chapters 1 - 4.

Name: ___________________________ Student Number: ______________________ 1) Given 4 bits to represent data in memory, what is the range of signed integers that can be represented if two’s complement representation is used? (5 points) Also, what is the binary representation for -9? ( points) range: (-8) – 7 -9 can’t be represented using only 4 bits and using 2’s complement representation 2) Given 4 bits to represent data in memory, what is the range of signed integers that can be represented if sign-and-magnitude representation is used? (5 points) Also, what is the binary representation for -1? ( points) range: (-7) – 7 -1 = 1001 3) Give the 8-bit representation of the numbers -10 and 100 in sign-and-magnitude and two’s complement representations and show how each representation is sign-extended to 16 bits. (10 points) sign-and-magnitude (-10): 1000 1010 sign extended: 1000 0000 0000 1010 two’s complement (-10): 1111 0110 sign extended: 1111 1111 1111 0110 sign-and-magnitude (100): 0110 0100 sign extended: 0000 0000 0110 0100 two’s complement (100): 0110 0100 sign extended: 0000 0000 0110 0100 4) Given that a program executes on computer A in 7 seconds. This particular program performs both floating point and integer operations. The floating point operations make up 40% of the total execution time of the program on machine A. Machine B incorporates new floating point hardware that can improve the time for floating point operations. By what amount does machine B need to improve the floating point operations of machine A in order to achieve a new execution time of 5 seconds? (10 points)

4. 2 sec

_ _

_ _ _ _.

_ _ _

^ 

speedup

speedup

Speedup

exetime unaffected

Speedup

executiontimeaffectedby imp

executiontimeafter improvemen t

5) Draw a 1-bit ALU capable of performing or supporting the instructions AND, OR, ADD, SUB, SLT. Show all data and control lines. (10 points) Then, draw a 4-bit ALU using an abstraction for the 1-bit

device you designed in part one of this question. Again, show all data and control lines. (10 points) Finally, complete a table showing all the values for the control signals needed to implement each of the instructions. (5 points)

So, machine 1 is 1.36 times faster than machine 2. 8) Reverse engineer the MIPS assembly code from the following machine code given in hexadecimal. ( points) 01 0C 80 24 and $s0, $t0, $t 9) Given the following C code and the assumptions, write the MIPS assembly for the calling function and the subroutine. Assume that variable a is allocated to register $s1, variable b is allocated to register $s2, variable c is allocated to register $s3, variable max is allocated to register $s4, variable m is allocated to register $s1, all input and output parameters are allocated according to the conventions used in MIPS assembly, and finally that any temporary registers needed will be allocated to a temporary register ($t0 - $t9). Preserve only those registers that must be preserved across the subroutine call. The MIPS assembly must be CORRECT assembly language instructions. NO Pseudo-instructions are allowed. (20 points) int maximum (int x, int y, int z) { int m; if ((x >= y) && (x >= z)) m = x; else if ((y >= x) && (y >= z)) m = y; else if ((z >= x) && (z >= y)) m = z; return (m); } void main (void) { int a, b, c, max; … max = maximum(a, b, c) … } main: add $a0, $zero, $s add $a1, $zero, $s add $a2, $zero, $s jal maximum add $s4, $zero, $v j done maximum: addi $sp, $sp, - sw $s1, 0($sp) slt $t0, $a0, $a slt $t1, $a0, $a or $t2, $t0, $t beq $t2, $zero, returnx

slt $t0, $a1, $a slt $t1, $a1, $a or $t2, $t0, $t beq $t2, $zero, returny slt $t0, $a2, $a slt $t1, $a2, $a or $t2, $t0, $t beq $t2, $zero, returnz returnx: add $v0, $a0, $zero j exit returny: add $v0, $a1, $zero j exit returnz: add $v0, $a2, $zero j exit exit: lw $s1, 0($sp) addi $sp, $sp, 4 jr $ra done:

11) Identify which addressing mode is used by each of the following instructions, and describe how the addressing mode creates the address of the operand(s). (4 points each) a) j label Pseudodirect addressing; 26 bits of immediate data in instructions is concatenated with top 4 bits of PC to create jump destination (word relative) b) ori $s0, $s1, 4 Immediate addressing; operand is in the instruction itself c) lw $s0, 0 ($s1) Base/displacement addressing; contents of base register ($s1) are added to immediate data in the instruction to get address of operand d) bne $t0, $t1, label PC-relative addressing; PC + 4 is added to immediate data in instructions to create address for branch (word relative)