Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. If C = 1, R3 = 0x78, and R4= 0x5B before execution of SBC R3, R4, what will b

ID: 2291608 • Letter: 1

Question

1. If C = 1, R3 = 0x78, and R4= 0x5B before execution of SBC R3, R4, what will be the contents of R3, R4, and C (carry flag) after execution? 2. Show the value of R20 after the following lines of code are executed LDI R20, 0x79 --> ? 1?ot LDI R21, 0x9F ? { 001 , , , EOR R20, R21 3. Consider the following code .EQU VALI 79 .EQU VAL2 = 25 LDI R21,VAL2R2 CP R21,R20 BRLO NEXT LDI R20, VAL2 25 NEXT a. What does the above ? Gr¼ b. What is the value of R20 after the above code is executed? NEA at is the value ofeprogramdo?Gm1Ave R014 R[o tev, biatch to

Explanation / Answer

1. SBC R3, R4 (Subtract with Carry)

R3 = R3 – R4 – Carry

R3 = 0x78 – 0x5B – 1 or (01111000 – 01011011 – 1) = 0x1C

Hence R3 = 0x1C, R4 = 0x5B and Carry = 0

2. LDI R20, 0x79 Load immediate hex value 0x79 into R20 register

LDI R21, 0x9F Load immediate hex value 0x9F into R21 register

EOR R20, R21 ; R20 = R20 exclusive OR R21

Hence R20 = (01111001 xor 10011111) = 11100110 = 0xE6

R20 = 0xE6

3. .EQU VAL1 = 79 ; VAL1 = decimal 79

.EQU VAL2 = 25 ; VAL2 = decimal 25

LDI R20, VAL1 ; Load immediate. Hence R20 = 79

LDI R21, VAL2 ; Load Immediate. R21 = 25

CP R21, R20 ; Compare by R21 – R20 and affect only flag without changing contents of R21 & R20. Hence 25 – 79 will affect carry =1

BRLO NEXT ; Branch if Lower or Branch if R21 < R20. Hence condition is TRUE and branch happens

LDI R20, VAL2Load Immediate R20 with VAL2 , This is not executed