CS计算机代考程序代写 mips Quiz5

Quiz5
Due No due date Points 10
Questions 6 Available until Feb 10 at 4:20pm Time Limit 60 Minutes
Instructions
You can take this quiz only once.
Once you start the quiz, you will need to complete it.
This quiz was locked Feb 10 at 4:20pm.
Attempt History
Attempt Time Score LATEST Attempt 1 20 minutes 10 out of 10
Score for this quiz: 10 out of 10 Submitted Feb 10 at 4:07pm This attempt took 20 minutes.
Question 1
Not yet graded / 1 pts
If you convert the integer -19 ten to 8-bit two’s complement, what would it be (in binary representation)?

Question 2
Not yet graded / 1 pts
Suppose that we have the integer 11011101 using 8-bit two’s complement. What is the decimal representation of this signed integer?
Your Answer: -35
Ans. – 35
Your Answer:
1110 1101
Ans. 1110 1101
Question 3
Not yet graded / 2 pts
What is the MIPS machine language code for the following instructions? (write it in binary numbers for each field such as opcode, rt).

3-a). addi $sp, $sp, -8
Your Answer:
opcode: 001000
rs: 11101
rt: 11101
immediate: 1111111111111000
Instruction: 00100011101111011111111111111000
Ans.
I – type
op rs rt const Decimal 8 29 29 -8
Binary 001000 11101 11101 1111 1111 1111 1000
Question 4
Not yet graded / 2 pts

What is the MIPS machine language code for the following instructions? (write it in binary numbers for each field such as opcode, rt).
3-b). jr $ra
Your Answer:
Instruction: 00000011111000000000000000001000 Opcode: 001000
rs: 11111
no rt
Ans.
R – type
op rs rt rd shamt funct Decimal 0 31 0 0 0 8
Binary 000000 11111 00000 00000 00000 001000
Question 5
Not yet graded / 2 pts

What is the MIPS machine language code for the following instructions? (write it in binary numbers for each field such as opcode, rt).
3-c). beq $a0, $v0, Label1
# where the current PC is at the memory address 0x0040002c, and the branch address is at the memory address 0x0040005c
Your Answer:
opcode: 000100
rs: 01001
rt: 01011
immdiate: 0000000000110000

Ans.
Branch addr = PC+4 + Const*4
where Const is the number to be used for the constant in the instruction
Const = (Branch addr – PC – 4) /4
= 1011 (in binary, 10 in decimal)
op rs rt const Decimal 4 4 2 11
Binary 000100 00100 00010 0000 0000 0000 1011
Question 6
Not yet graded / 2 pts
What is the MIPS machine language code for the following instructions? (write it in binary numbers for each field such as opcode, rt).
3-d). j Label2 # where the jump address is at memory address 0x0040011c

Your Answer:
opcode:000010
jump address:
0000 0100 0000 0000 0001 0001 11
Ans.
Branch addr = append the most significant 4 bits of PC+4 before Const * 4
where Const is the number to be used for the constant in the instruction
0x0040011c
=
0000 0000 0100 0000 0000 0001 0001 1100
Now the first 4 bits come from PC+4, so we can discard it. Also, we need to divide it by 4, that means, shift right by 2 bits by discarding the right most 2 bits:
0000 0000 0100 0000 0000 0001 0001 1100
We have:
0000 0100 0000 0000 0001 0001 11 to be used as a constant.
Const = 2^20+2^6+7= 1048576+64+7=1048647

Quiz Score: 10 out of 10 This quiz score has been manually adjusted by +10.0 points.
So:
op const
Decimal 2 1048647
Binary Instruction is: 000010 0000 0100 0000 0000 0001 0001 11
ten
Const = 2^20+2^6+7= 1048576+64+7=1048647