Which of the following code snippets will branch to the label, is_one, only if b
ID: 3585108 • Letter: W
Question
Which of the following code snippets will branch to the label, is_one, only if bit 0 of $t0 contains the value, 1? Hint: Make sure you understand "bit masking"
A. andi $t0, $t0, 0
beq $t0, $0, is_one
nop … # code for when bit 0 of $t0 is zero is_one: … # code for when bit 0 of $t0 is one …
B. andi $t0, $t0, 0
bne $t0, $0, is_one
nop … # code for when bit 0 of $t0 is zero is_one: … # code for when bit 0 of $t0 is one …
C. andi $t0, $t0, 1
beq $t0, $0, is_one
nop … # code for when bit 0 of $t0 is zero is_zero: … # code for when bit 0 of $t0 is one …
D. andi $t0, $t0, 1
bne $t0, $0, is_one
nop …
# code for when bit 0 of $t0 is zero is_one:
… # code for when bit 0 of $t0 is one
Explanation / Answer
C
andi. $t0, $t0, 1
# it perform And operation
beq $t0, $0, is_one # it check equal or not
nop …-
# code for when bit 0 of $t0 is zero
is_one:
… # code for when bit 0 of $t0 is one
Option d I correct.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.