Answer Key
University
California State UniversityCourse
COMP 122 | Computer Architecture and Assembly Language and LabPages
1
Academic year
2023
anon
Views
52
COMP 122-16396-FA2.. > Quizzes > CSUNCOMP122Amini... CSUNCOMP122Amini_Midterm Due Oct 13, 2022 at 4:30pm Points 100 Questions 47 Available Oct 13, 2022 at 2:30pm - Oct 13, 2022 at 4:30pm 2 hours Time Limit None This quiz is no longer available as the course has been concluded. Attempt History Attempt Time Score LATEST Attempt 1 96 minutes 100 out of 100 Score for this quiz: 100 out of 100 Submitted Oct 13, 2022 at 4:06pm This attempt took 96 minutes. Question 1 2/2 pts What comes after the binary number 0111?? 0000 0110 Correct! 1000 1111
Question 2 2/ 2 pts What is the binary equivalent of the hexadecimal number 48? 10000100 Correct! 01001000 11011011 11100001 Question 3 2/2 pts What is the decimal equivalent of the hexadecimal number 2A? Correct! 42 24 10 12 Question 4 2/2 pts What is the value of 210 base 6 in decimal? Correct! 78 38 8 18
Question 5 2 2 pts Identify the value obtained after converting1568 to base 6. Correct! 3026 2036 206 366 Question 6 3/ 3 pts Consider the given table. Identify the syntax used to update the 3rd element of myArray with 144. myArray 0 25 1 36 2 49 3 64 4 81 5 100 6 121 Correct! C myArray[2] 144 myArray[144] 2 myArray[3] 144 myArray[144] 3 Question 7 2/ 2 pts Given array Grades has 5 elements, which is true? Grades[1] is the first element of the array Grades[5] = 90 assigns the value 90 to the last element of the array Correct! Grades[4] - 90 assigns the value 90 to the last element of the array Grades[2] is the second element of the array
Question 8 3/ 3 pts Given the following register file contents, what will be the value of $t2 after executing the instruction sequence? add $t2, $t3, $t3 mul $t2, $t2, $t2 Register file $t1 4 $t2 5 $t3 2 4 Correct! 16 25 36 Question 9 0/2 pts Which of the following instruction sequences is equivalent to $t3 = $t2+3*$t1? You Answered mul $to, $t1, 3 add $t3, $t2, $to add St3, $t2, $t1 mul $t3, $t1, 3 addi Ste, Sto, 3 mul Sto, Ste, $t1 add $t3, $t2, $to Correct Answer addi $to, $zero, 3 mul $to, $to, $t1 add $t3, $t2, $to
Question 10 3/3 pts Given the following register file contents, what is the value of $t3 after executing the instruction sequence? bne $t1, $t2, L1 addi $t3, $t3, 5 L1: addi $t3, $t3, 5 Register file $t1 5 $t2 5 $t3 10 10 15 Correct! 20 25 Question 11 2/2 pts Which of the instruction sequences is equivalent to the following expression? if ($t1 1- $t2) $t3 $t3 1 Correct! beg $t1, $t2, L1 addi $t3, $t3, -1 L1: beg $t1. $t2 L1 sub $t3, $t3, 1 L1: one $t1, St2, L1 addi St3, St3, -1 L1: bne Stl, St2, L1 sub $t3, $t3, 1 L1:
Question 12 3 pts Which of the instruction sequences is equivalent to the following expression? if (Sti St2) St3 St3 1 else $t3 $t3 1 Correct! bne $t1, $t2, L1 addi St3, St3, -1 1 L2: L1: addi St3, $t3, 1 L2: . one St1. St2, L1 sub St3. St3, 1 1 L2: 11: addi $13. $13. 1 12: . beg Sti, St2, LI addi St3, St3, -1 1 12: Ll: addi $t3, $t3, 1 L2: D beg Stl, St2, U sub St. St., 1 1 12 Li: addi $13. $13, 1 12 o Question 13 3/3 pts Which of the expressions is equivalent to the following instruction sequence? one St2, St3, L1 add Stl, St2, $zero 1 L2 11: add St1, st3, $zero L2: Correct! if (St2 $13) Sts St. else St $13 . 1 if (St2 St3) Sti ST. else St St3 e If (st2 $13) Stl Stl St2 else Stl $13 e if (St2 $t3) su $12 else Stl Stl St3 .
Question 14 2/2 pts Which of the following instruction sequences is equivalent to the instruction ble ste, St1, BLabel ? Correct! slt $t2, $t1. sta beg $t2, $zero, BLabel slt $t2 Ste. Stl beg St2, $zero, BLabel slt $t2, $t1, ste one $t2, $zero, BLabel slt $t2, Sto. $t1 one $t2, $zero, BLabel Question 15 2/ pts Which of the instruction sequences is equivalent to the following expression? if ($to 0) $t1 St 1 else $11 $11 . 1 Correct! slt St2, $zero, $10 bne $t2, $zero, True addi $t1, Sti, 1 1 End True: addi $t1, St1, 1 End: slt St2, Sto, $zero one St2, Szero, True add1 Sti, Sti, -1 End True: addi St1, St1, 1 End: slt St2, $zero. Ste beg St2. $zero, True addi Stl, Sti, -1 j End True: addi St1, St1, 1 End: slt St2, Ste, Szero baq $t2. $zero, True addi $t1. Stl. -1 1 End True: addi Stl. $t1, 1 End:
Question 16 3/ pts Which of the expressions is equivalent to the following instruction sequence? slt $t2, $10, $t1 beg $t2, $zero, L3 sub $t3, $t1, ste J End L1: sub St3, Sto, $t1 End: Correct! if ($to $t1) $t3 $t1 ste else $t1 $te $11 . ) if ($to $t1) $t3 $t1 Ste else St1 $te St1 if ($to $t1) $11 ste $11 else $t3 $t1 Ste if (Ste $t1) Sti Ste St1 else $13 $11 ste Question 17 2/2 pts Which of the instructions is equivalent to the following instruction sequence? sit ste. $t2. $t1 beg ste, $zero, BLabel Correct! bge St2. Stl. Blabel bgt St2. Sti. Blabel ble St2 St1, Blabel blt St2, Sti, Blabel
Question 18 2/2 pts Given the following data memory (DM) and assuming StO holds 5304. $t1 holds 5308 which instruction sequence performs the operation DM[5308] - DM[5300]? Data memory (DM) 5300 10 5304 20 5308 30 la Ste, -4($t1) SH ste. 4($11) lie ste. 4(511) SW ste. 4($11) Correct! lw $t1, -4($(0) SM $t1, 4(ste) ) la $t1. 4(ste) SW Stl. -4($to) Question 19 2/ pts Given x's address . 4000, what are the assembly instructions for the following C statements? int K; x - 10; addi Ste, Szero, 10 addi Stl. Szero. 4000 l $t1. @($te) addi Sto. $zero, 10 addi Sti. $zero, 4000 SH $t1. e(ste) addi sto. $zero, 10 addi Stl. Szero, 4000 la ste, @($t1) Correct addi ste, $zero, 10 addi $t1, $zero, 4000 SH sto. a($t1)
Question 20 2/2 pts Given x's address - 4000 and y's address = 4004. complete the assembly instructions for the following C statements int x; int y y x; Assembly instructions: addi Ste, $zero, 4000 addi $t1, $zero, 4084 ... Correct! lw $t2, e($ta) SW St2, e($t1) lw St2, e($t1) SW St2, 0($t0) Sw St2, 0(St0) la St2, e($t1) SW St2, e($t1) lw St2. 0($to) Question 21 2/2 pts Given x's address - 5000. which C statement does the following assembly carry out? addi $to. $zero, 5000 lw $11, e($to) addi St1. $t1. 1 SW $11, e($to) x = 1 - 5000 Correct! x 5000
Question 22 2/2 pts Assume $t3 has x's value, $t4 has y's value, and $t5 has z's value, what are the assembly instructions for the following C statements? y-y-x*z sub Ste. St4, St3 mul $t4, ste, $t5 sub Ste, St3, St5 mul $t4,$t4,$t0 mul $te, St4, St3 sub $t4, $to, $t5 Correct! mul ste, St3, $t5 sub St4, St4, ste Question 23 2/2 pts Assume $t2 has x's value, $t3 has y's value, and $t4 has z's value, what C statement does the following assembly carry out? add ste, $t2, $t3 sub St2, St2, $t3 mul $t4, Sto, $t2 x = x + x y 0 z= x + x*y x - (x y y)*(x - y) - Correct! z - (x y y)*(x - y)
Question 24 2/2 pts Assume $t0 has x's value, $t1 has y's value, and $t2 has z's value. convert the following C statements to assembly if (y z) ( ) x 1: boq Sti, St2, After add Ste, Stl. $zero After: addi ste. $10. , Correct! bne $11, $t2, After add Ste, Sti, $zero After: addi ste. ste, J beg Stl, St2, After addi Ste. Ste. After add $to. $t1. Azero boe Sti. St2. After add) Ste. Ste. 1 After add ste, $11. $zero Question 25 2/2 pts Assume St0 has x's value. $t1 has y's value. and $t2 has z's value. convert the following C statements to assembly. if (y - z) ( x y y 5 ; ) else ( beg Stl. St2. Else addi Ste. Stl, 5 I After Else: add sto. St2, %zoro After addi ste. Ste, 3 Correct! boe $11. St2. Else addi Ste. Stl. 5 1 After Else: add ste, St2, $zero After: addi ste, ste, 3 . beg Stl. St2, Else add Ste. St2. Szero Else: addi Sto. Stl, 5 After addi ste. Ste. 3 bne Stl, St2, Else add Ste, St2, Szero Else: addi $10. $11. 5 After addi Ste ste 3
Question 26 2/2 pts Assume StO has x's value. St1 has y's value. and St2 has z's value. convert the following C statements to assembly if (x == y) ( 2-X 1 else if (y - 0) ( 1 else I VI Correct bre sto, Stl, Elsel add st2, Ste, $zero 1 After Elsel: one $11. $zero, Else? add $t2, $10, $zero After Else} add St2. St1. $zero After beg ste. SEL Elsel add St2, ste, Szero 1 After 11001 bed $11. $24.00 Elsea add $12. ste. szero ) After 11402 add $12. stl. $2000 After one ste. $12. (Ise add st2, ste. Szero 1 After Use be Stl. Szero, After add St2. Ste. Szero After add St2, Stl. Szero ben ste, $t3, Else add st2 STO. $zorn After Else bed Stl. Szero After add $12, ste. Szero After add St2, $t1, $zero Question 27 2/2 pts Assume StO has x's value and St1 has y's value, convert the following C statements to assembly. if (x 1- 1) ( * ) x 1: Correct beg ste. $t1, After add ste. Sti. $zero After: addi ste, sto. 1 one ste. Stl. After add ste. Stl. Szero After addi Ste. ste, 1 boo sto, Stl. after addi ste. Ste. After add ste. SEI, szero one ste. Stl. After adds Ste. Ste. 1 After w55 sto, Stl. Szero
Question 28 2/ pts Assume $t0 has x's value, $t1 has y's value. and $t2 has z's value. convert the following C statements to assembly. if (y
Question 30 2/ pts Assume is in StO and is in $t1. Convert the following C statements to assembly . 5: while (x e) [ y-y+2; ) Correct! addi ste. $zere, Loop: ble Ste. $zero, After addi $11, $11. addi 1 LOOD After - adds Ste. Szero, LOOD: bet ste. Szero, After addi Stl. Stl. addi Ste. Ste. , Loop After addi Ste, Szero, LOOD: ble sto. Szero, After add ste. sto. addi Sti, Stl. 1 Loop After add $10, $zero LOOP egt ste. Szero, After addi Ste. Sto. addi $11. $11. 3 Loop After Question 31 2/ pts Assume is in $to and is in $11. Convert the following C statements to assembly for (x 2: x 10; , ( y; ) Correct! addi Ste, $zero 2 adds St2. $zero, 10 LOOD bee ste. $t2 After add $11. ste. $11 addi Ste. Ste. 2 Loop After . addi ste. $zero, LOOD: bee ste. $11. After add Sts. $18 $11 addi ste. ste. 2 Loop After adidas ste. $2000. addi $12. Steen 10 LOOD blt Ste. St.2. After add Stl. Ste. $11 addi Ste. Ste 2 Loop After addi Ste. Szere, LOOD: hit ste. Sti, After add Stl. Ste. St) 2531 ste. STOP 2 LOOO After
Question 32 2/2 pts Assume $t0 stores the base address of X. Convert the following C statement to assembly. x[2] 4; addi $t1, szero, 4 Str $t1, 2(ste) addi St1, Szero, 4 SM St1, 4(Ste) add Stl. szero, 4 SW St1. 6(ste) Correct! addi $t1. $zero, 4 SM $t1, B(Ste) Question 33 0/2 pts Assume y's base address is in DM[5000]. Convert the following C statement to assembly. y[a] y(2) y[1]: addi sto. Szero, 5000 lw St1, a(ste) IM St2, 1(ste) add St3, St2, $t1 SM St3, 2(Ste) O addi Sto, Szero, 5000 lw Stl, 1(ste) lm St2, 2(Ste) add St3, St2, $t1 SM St3, 3(ste) You Answered addi Ste, $zero, 5000 1w Sti, 0($t0) la St2, 4($to) add $t3, $t2, $t1 SW St3, 8($to) Correct Answer addi Sta, $zero. 5000 la $t1, 4($te) la $t2, ste) add $t3, St2, $t1 SM $t3, 12($te)
Question 34 2/2 pts Assume x's base address is in $t0 and is in $t1. Convert the following C statement to assembly. i e; while (i < 4) ( x[i] x(1) 1; 1 i; ] addi $t1, $zero, 0 addi St2, $zero, 4 Loop bge $t1 $t2, After add $t3, $t1. $to lw St4, 0($t3) addi $t4 $t4 1 SW $t4, 0($t3) addi $t1. Sti, 1 1 Loop After Correct! addi $t1, $zero, a addi $t2, $zero, 4 Loop: bge $t1, $t2, After mul $t3, St1, $t2 add $t3, St3, $to lw $td, a($t3) addi $t4, $t4, 1 SW $t4, e($t3) addi $t1, $t1, 1 1 Loop After: addi $t1. $zero, e add1 $t2 $zero, 4 Loop: blt Stl. $t2, After add St3, $t1, $te In St4, 0($t3) add) $t4, $t4, 1 SW St4, 0($t3) addi $t1. Stl. 1 1 Loop After addi $t1, $zero, 0 addi St2. $zero, 4 Loop: bit Stl. $t2, After mul St3, St1, $t2 add St3, St3, Ste Iw St4, 0($t3) addi Sta, St4, 1 SW St4, 0($t3) addi $t1, Stl, 1 j Loop After Question 35 2/2 pts y = a'(b + c) is an example of an expression table Correct! equation complement equation
Question 36 2/2 pts For the circuit below, what should be the y, Z values at position (1)? a a y b b Z C C y Z (1) (2) y=0,z=0 y=0,z=1 y=1,z=0 Correct! y=1,z=1 Question 37 2/2 pts For the circuit below, what should be the y, Z values at position(2)? a a y b b Z c c y Z (1) (2) Correct! y=0,z=0 y=0,z=1 y=1,z=0 y=1,z=1
Question 38 2/2 pts The given circuit translates to which equation? a y b C y=a'+b'+c y=a'b'+c Correct! y=a'+ b'c y=a'+bc Question 39 2/2 pts Which sum-of-product equation matches the circuit provided? e f y g y=ef'(f'+g') y ( ef')(f'g') y = (ef)'+ ( (fg)' Correct! y=ef + fg'
Question 40 2 / 2 pts The following equation is converted to sum-of-products form. Indicate the product term that corresponds to the "?" below. Note: Simplify when possible. =e'(f' y=e'f'+? e'fg Correct! e'g fg' f' + g Question 41 2/2 pts The following equation is converted to sum-of-products form. Indicate the product term that corresponds to the "?" below. Note: Simplify when possible. y = a(b'c' + ab) ab'c' + ? b Correct! ab 1 0 Question 42 2 / 2 pts Counting up from 010, which of the following list the next three binary numbers? 010. 100. 001, 010 010,001,100,010 010.011.000.001 Correct! 010.011.100.1 101
Question 43 2/ 2 pts Which of the following 4-bit binary numbers is equivalent to the decimal number 12? 0111 1010 1110 Correct! 1100 Question 44 2/2 pts How many rows does a truth table contain for a 2-input function? 3 Correct! 4 8 16 Question 45 2/2 pts What is the value of function f = a'b )+ab'whena=1,b=0 a b f(a, b) 00 0 0 1 1 1 0 ? 11 0 0 Correct! 1 10 Unknown
Question 46 2/2 pts Circle (P) is what simplified term? b a 0 1 0 1 1 1 P 1 0 Correct! C b' a ab' a'b' Question 47 2/2 pts Which of the following results in the best simplification? Note: Each circle is denoted by parenthesis. (A, B) indicates that a circle includes cells A and B. b a 0 1 0 0 (H) 1 (J) 1 1 (L) 0 (K) (H, L), (J.K) Correct! (J), (L) (J. L) (J. L), (H, K) Quiz Score: 100 out of 100 This quiz score has been manually adjusted by +4.0 points.
COMP 122 Midterm Exam Quizzes
Please or to post comments