Trace the assembly code segment as provided for a =1 and b=4. Show values for an
ID: 663838 • Letter: T
Question
Trace the assembly code segment as provided for a =1 and b=4. Show values for any register that has changed. Also, rewrite the assembly language code segment below to correct any errors so that the code correctly translates the C code below. Provide a couple of sentences to justify your answer. Assume all registers have been defined.
if a > b
then a += b
else {
c = a * b
b = a }
mov 10, %o0
cmp %a_r, %b_r
bl,a else
add %a_r, %b_r, %a_r
else:
mov %a_r, %o1
mov %b_r, %o2
call .mul
mov %b_r, %a_r
mov %o0, %c_r
done:
Explanation / Answer
the first one is the pseudo code for the given assembly code.
the value of c will be 4 and value of b will be 1 after the assembly code is completed.
a_r will have 1
b_r will have 1
c_r will have 4
o0 will have 4 value.
this is the code which gets executed
mov %a_r, %o1
a_r will become 1
mov %b_r, %o2
b_r will become 4
call .mul
multiplication will happen on o0 o0 will get value 4
mov %b_r, %a_r
b_r will become 1 now
mov %o0, %c_r
c_r will become 4
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.