//i am asuming you are willing to find out how the 2 programs
work
1.
Ser r16
Mov r15,r16
Mov r14,r16
explaination:
here first instruction is Ser ie set all
bits
setting all bits means 1111111111111111
which is in 2's compliment form
equivalent decima number of this is -1
so we are loading -1 in r16
2nd and 3rd instructions are Mov, here 1st
register is destination and 2nd is source
hence we are putting -1 in both registers r14
and r15
2.
Mov r17,r15
Mov r16,r14
Lsl r14
Rol r15
Lsl r14
Rol r15
Add r14,r16
Add r15,r17
explaination:
1st and 2nd are Mov instructions as described
above, here we are loading r17 with r15 and r16 with r14
3rd instruction is Lsl, lets see what it
does:
Shifts all bits in R14 one place to the left.
Bit 0 is cleared. Bit 7 is loaded into the C flag of the status
register
This operation effectively multiplies r14 by
two.
next instruction is Rol which is Rotate Left
trough Carry, let's see what it does:
Shifts all bits in r15 one place to the left.
The C flag is shifted into bit 0 of Rd. Bit 7 is shifted into the C
flag
as this is mentioned that r15 is most
significant byte so what we are doing with Rol is multipliying it
by two with
carry generated through Lsl
so till now we have multiplied r14:r15 with two
next 2 instructions are again Lsl and Rol which again multiplies r14:15 by two
so till now we have multiplied r14:r15 with four
next two instructions are Add instructions where we are adding r16 to r14 and r17 to r15
equivalent high level code:
r17=r15
r16=r14
r14=2*r14
r15=2*r15
r14=2*r14
r15=2*r15
r15=r15+r17
r14=r14+r16
so finally we have multiplied r14:r15 by 5
COMMENT DOWN FOR AN QUERY
PLEASE GIVE A THUMBS UP
Please help by showing steps. Question 4. (continued) (b) Consider a 16-bit binary number stored in AVR registers r1...