Quiz 3

advertisement
Quiz 3
ECE 484/584 -- Fall 2003
Chapters 1 – 4.4
Name: __________________________
Student Number: ______________________
1) Push $s1 and $s2 onto the stack. Show all necessary MIPS instructions. Draw the stack and show the
old stack pointer, the new stack pointer, and the locations of $s1 and $s2. (5 points)
addi
sw
sw
$sp, $sp, -8
$s1, 0($sp)
$s2, 4($sp)
Old SP
$s2
$s1
New SP
2) As a continuation of problem #1, pop $s1 and $s2 off of the stack. Show all MIPS instructions. Make
sure that you leave the stack as it was BEFORE you pushed values onto it. (5 points)
lw
lw
addi
$s1, 0($sp)
$s2, 4($sp)
$sp, $sp, 8
3) What addressing mode is used for each instruction? Describe how the addressing mode accesses the
operands. (3 points each)
a) lw
$t0, 0 ($s0)
base/displacement addressing mode
constant offset stored in the instruction (0) is added to the base register contents ($s2) to create the address
of the operand
b) sll
$t0, $t1, 8
register addressing mode
operands are stored in registers
c) andi $t1, $t2, 16
immediate addressing mode
operand (16) is encoded as part of the instruction itself
d) bne $t0, $t1, label
PC-relative addressing mode
The contents of the PC are added to the value stored in the label field of the instruction to determine the
branch location.
e) j
label
pseudo-direct addressing mode
The four MSbits of the PC are concatenated with the 26 bits from the label field of the instruction to create
a 30-bit word address for the jump.
4) Given a 4-bit representation, list all the binary numbers with their decimal equivalents that can be
represented if unsigned integers are represented. (7 points)
0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = 10
1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15
5) Given a 4-bit representation, list all the binary numbers with their decimal equivalents that can be
represented if two’s complement representation is used. (8 points)
0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = -8
1001 = -7
1010 = -6
1011 = -5
1100 = -4
1101 = -3
1110 = -2
1111 = -1
Download