comp arch
We discussed the simplied instruction fetch cycle. What is the instruction fetch cycle? What hardware is used during the instruction fetch cycle; be specic please?d
Cpu sends contents to MAR, memory returns the data stored, cpu copies the data from data bus into mdr, cpu copies data from mdr to instruction register, the pc is incremented
Assuming the following are unsigned integers. Does overflow occur when adding these two numbers? Briefly explain why/why not and how to detect overflow when adding unsigned binaries. 010101 + 010111
Overflow does NOT occur because the carry out of the most significant bit is zero.
Assume the following are 2's compliment integers. Does overflow occur when adding these two numbers? Briefly explain why/why not and how to detect overflow when adding 2's compliments. 010101 + 010111
Overflow does occur because the carry in to the most significant bit is not the same as the carry out of the most significant bit
What is the format type for this instruction "slt $t2, $s2, $s4"
R-type
You will be writing partial code for a procedure. Write MIPS Assembly language code to push three registers $s0, $s1 and $s2 onto the stack, then restores the contents of these registers and returns control to the calling procedure. Provide comments for each line of your code to receive credit; points taken o if comments are not given.
addi $sp, $sp, -12 # make room for 3 4-byte values sw $s0, 0($sp) # push s0 sw $s1, 4($sp) # push s1 sw $s2, 8($sp) # push s2 lw $s2, 8($sp) # pop s2 lw $s1, 4($sp) # pop s1 lw $s0, 0($sp) # pop s0 addi $sp, $sp, 12 # restore the stack pointer
Briey explain how the lui and ori are used together to load a large constant into memory.
lui loads upper 16 bits and than ori loads the lower 16 bits by oring the remaining zeros thus we get the full 32 bit value
Assume the MIPS assembly language procedure Betty invokes procedure Al. Al uses registers $a0, $t0, $s0 and Al is a leaf procedure. Betty uses registers $t0 and $s0 and passes the argument to Al in register $a0. Consider the MIPS Register Conventions for Procedures. To be safe (that is to not overwrite variables) and to be efficient (that is use the smallest number of instructions), Should Al save register $a0?
no
Assume the MIPS assembly language procedure Betty invokes procedure Al. Al uses registers $a0, $t0, $s0 and Al is a leaf procedure. Betty uses registers $t0 and $s0 and passes the argument to Al in register $a0. Consider the MIPS Register Conventions for Procedures. To be safe (that is to not overwrite variables) and to be efficient (that is use the smallest number of instructions), Should Betty save register $s0?
no
Assume the MIPS assembly language procedure Betty invokes procedure Al. Al uses registers $a0, $t0, $s0 and Al is a leaf procedure. Betty uses registers $t0 and $s0 and passes the argument to Al in register $a0. Consider the MIPS Register Conventions for Procedures. To be safe (that is to not overwrite variables) and to be efficient (that is use the smallest number of instructions), Should Al save register $s0?
yes
Assume the MIPS assembly language procedure Betty invokes procedure Al. Al uses registers $a0, $t0, $s0 and Al is a leaf procedure. Betty uses registers $t0 and $s0 and passes the argument to Al in register $a0. Consider the MIPS Register Conventions for Procedures. To be safe (that is to not overwrite variables) and to be efficient (that is use the smallest number of instructions), Should Al save register $t0?
yes
Assume the MIPS assembly language procedure Betty invokes procedure Al. Al uses registers $a0, $t0, $s0 and Al is a leaf procedure. Betty uses registers $t0 and $s0 and passes the argument to Al in register $a0. Consider the MIPS Register Conventions for Procedures. To be safe (that is to not overwrite variables) and to be efficient (that is use the smallest number of instructions), Should Betty save register $a0?
yes
Consider the instruction "slt $t2, $s2, $s4" What is the shamt eld in binary using the required number of bits for representing the shamt eld in the machine language instruction or write DNE if it does not exist? My answer is _____.
00000
Consider the instruction "slt $t2, $s2, $s4" . What is the opcode in binary using the required number of bits for the opcode in the machine language instruction or write DNE if it does not exist? My answer is _____.
000000
Consider the instruction "slt $t2, $s2, $s4" What is the OPcode code in binary using the required number of bits for representing the funct code eld in the machine language instruction or write DNE if it does not exist? My answer is _____.
000000
Assume the contents of memory as displayed below and the value in $t0 is 0x0000011C and the value in $t1 is 0x00000120. The contents of register $t1 after executing the instruction "lhu $t1, 2($t0)" given in binary is _____.
00000000000000001111101001011010
Assume the contents of memory as displayed below and the value in $t0 is 0x0000011C and the value in $t1 is 0x00000120. After executing the instruction "sb $t1, 4($t0)" the contents of the word in memory that changed, given in binary, is _____.
00100000101100000111101001010100
Consider the instruction "slt $t2, $s2, $s4" . What is the rd eld in binary using the required number of bits for representing the rd eld in the machine language instruction or write DNE if it does not exist? My answer is _____.
01010
Assume register $t0 contains 0x00000002 and $t1 contains 0x00000003. After executing the instruction "sll $t1, $t0, 6" the contents of register $t0 given as a hexadecimal number, preceded with 0x, is _____.
0x00000002, 00000002, 0x2, 2
Assume register $t0 contains 0x00000010 and $t1 contains 0x00000003. After executing the instruction "srl $t1, $t0, 3" the contents of $t1 given as a hexadecimal number, preceded by 0x, is _____.
0x00000002, 00000002, 0x2, 2
Assume register $t0 contains 0x00000010 and $t1 contains 0x00000003. After executing the instruction "srl $t1, $t0, 3" the contents of $t0 given as a hexadecimal number preceded by 0x is _____
0x00000010, 00000010, 0x10, 10
Assume register $t0 contains 0x00000002 and $t1 contains 0x00000003. After executing the instruction "sll $t1, $t0, 6" the contents of register $t1 given as a hexadecimal number, preceded with 0x, is _____.
0x00000080, 00000080, 0x80, 80
Assume the contents of memory is displayed below and the value in $t0 is 0x0000011C and the value in $t1 is 0x00000120. After executing the instruction "sb $t1, 4($t0)" the word in memory that changed is at address _____. Please give the address as an 8digit hexadecimal number as shown below, preceding your answer with 0x
0x00000120
Consider the instruction "slt $t2, $s2, $s4". Write the instruction as a hexadecimal number as it would be stored in memory; precede your hexadecimal number with 0x. My answer is _____.
0x025450AA, 025450AA, 0x25450AA, 25450AA
Consider the instruction "slt $t2, $s2, $s4" What is the rs eld in binary using the required number of bits for representing the rs eld in the machine language instruction or write DNE if it does not exist? My answer is _____.
10010
[1 point] Short answer. Consider the instruction "slt $t2, $s2, $s4" What is the rt eld in binary using the required number of bits for representing the rt eld in the machine language instruction or write DNE if it does not exist? My answer is _____
10100
Consider the instruction "slt $t2, $s2, $s4" What is the funct code in binary using the required number of bits for representing the funct code eld in the machine language instruction or write DNE if it does not exist? My answer is _____.
101010
Using the smallest number of bits necessary, convert -43 to a 2's compliment binary number. My answer is _____.
1010101
Using the smallest number of bits necessary, convert the decimal integer 43 to an unsigned binary number. My answer is _____.
101011
Using the smallest number of bits necessary, convert -43 to a signed magnitude number binary number. My answer is _____.
1101011
Assume the contents of memory as displayed below and the value in $t0 is 0x0000011C and the value in $t1 is 0x00000120. The contents of register $t1 after executing the instruction "lh $t1, 2($t0)" given in binary is _____.
11111111111111111111101001011010
Assume we have a maximum of 5-bits to represent an integer. The largest 2's compliment integer, written as a decimal number, is _____. Give your answer as a decimal number.
15
Assume we have a maximum of 5bits to represent an integer. The largest signed magnitude integer, written as a decimal number is _____. Give your answer as a decimal number.
15
Assume we have a maximum of 5-bits to represent an integer. The largest unsigned integer, written as a decimal number, is _____. Give your answer as a decimal number
31
Assume the MIPS assembly language procedure Betty invokes procedure Al. Al uses registers $a0, $t0, $s0 and Al is a leaf procedure. Betty uses registers $t0 and $s0 and passes the argument to Al in register $a0. Consider the MIPS Register Conventions for Procedures. To be safe (that is to not overwrite variables) and to be efficient (that is use the smallest number of instructions), Should Betty save register $t0?
yes
Assume we have a maximum of 5-bits to represent an integer. The smallest signed magnitude integer, written as a decimal number, is _____? Give your answer as a decimal number.
-15
Assume we have a maximum of 5-bits to represent an integer. The smallest 2's compliment integer, written as a decimal number, is _____. Give your answer as a decimal number.
-16
Assume we have a maximum of 5-bits to represent an integer. The smallest unsigned decimal integer, written as a decimal number, is _____. Give your answer as a decimal number.
0
Convert the binary number 10100011111110001100010111101001 to hexadecimal. My answer is _____.
A3F8C5E9
Assume register $t0 contains 0x00000010 and $t1 contains 0x00000003. What is the arithmetic effect of the instruction srl $t1, $t0,
The contents of $t0 is divided by 2^3 = 8.
Assume register $t0 contains 0x00000002 and $t1 contains 0x00000003. What is the arithmetic effect of the following instruction sll $t1, $t0, 6
The contents of $t0 is multiplied by 2^6 = 64.
Assuming the following are signed magnitude, does overflow occur when adding these two numbers? Briefly explain why/why not and how to detect overflow when adding signed magnitude. 010101 + 010111
The reason overflow occurs is that the sum is a negalive number and the sum should be a positive number when adding two positive numbers.
Explain what the jal and ra instructions do
jal is jump and link, address of following address pu in $ra, and then jump to target address ra is the return address to jump back to
Assume variable a is in $t2, variable b is in $t3, and variable c is in $t4. Rewrite the following C code in MIPS assembly language commenting each line of your code. You may NOT use the pseudoinstructions blt, bgt, ble, bge, li or move instructions. Hint: you may use beq, bne, slti, or slt if you wish. You MUST comment each line of your code explaining the portion of C pseudocode it performs. The C code follows. if a < b c = c+1; else c = c-1;
slt $t5, $t2, $t3 beq $t5, $zero, ELSE addi $t4, $t4, 1 j DONE ELSE: addi $t4, $t4, 1 DONE: