Hi, I am studying for a test and need some help deciphering the following Assemb
ID: 3671361 • Letter: H
Question
Hi, I am studying for a test and need some help deciphering the following Assembly Language code:
mov 14, %o1
subcc %o1, 4, %o0
ble else
sub %o0, 5, %o2
call .mul
add %o1, 5, %02
ba done
clr %o2
else: sub %o0, 7, %o0
call .mul
add %o1, 9, %o2
done: nop
please include comments for each step through the code, explaining what each line does, and please also tell me what the final values of %o0, %o1, %o2
Thank you, I will thumb up all good answers
Explanation / Answer
mov 14, %o1 !move 14 into %o1
2 subcc %o1, 4, %o0 !sub 4 from %o1 and store result in %o0
3 ble else !branch if %o0 less than or equal to %o1
4 sub %o0, 5, %o2 !sub 5 from %o0
5 call .mul ! multiply
6 add %o1, 5, %02 !add and store in %02
7 ba done !branch to the label done
8 clr %o2 ! clear reg
9 else: sub %o0, 7, %o0 !
10 call .mul
11 add %o1, 9, %o2
12 done: nop
%o0=10
%o1=42
%o2=51
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.