Q1 (40 points, 10 parts 4 points each) ach of following instructions is individu
ID: 2265883 • Letter: Q
Question
Q1 (40 points, 10 parts 4 points each) ach of following instructions is individually executed. Prior to the execution, assume that A = $87, [B]-$65, [X) = SFFFF.[Y] = S4321 , [S 1000] = $43. [S 1001]-$23, bits N. Z and C of CCR are 0, 0, and 1 respectively. Determine the result of execution and the N, Z and C bits after the execution of each of the following instructions. If the instruction does not affect any of those bits just put letter"n” Hint: [A] = content of accumulator A, [B] = content of accumulator B, [X)= content of register X, [Y]= content of register Y, [S1000-content of memory location $ 1000, [S 1001 ] = content of memory location $1001 . Instruction Result 1. SUBD 2. ABY 3. CPY 4. LSRD 5. ADCB 6. ROLB 7. TSTB 8. SBCB 9. EORA 10.INX $1000 $1000 #SEC #515 #S65Explanation / Answer
Answer:- N is set when result is negative,
C is set when result is not adjusting in given memory,
Z is set when result is zero and
V is set when sum of positive produces negative result or sum of negative produces positive result.
1) SUBD $1000 :- This will subtract value stored at address $1000 from register D i.e A:B.
Contents in D = $8765, value at address $1000 is $23, $8765 - $23 = $8742. So D = $8742, no CCR flag (N, Z, V) are affected here beacuse result is not negative, not zero, not overflowing and no borrow is comming out from this subtraction. Yes C bit changes to zero as initially it is set.
2) ABY :- Content of B and Y are added then stored in Y. Here B = $65, Y = $4321, So Y = $4386. This instruction does not afftect any CCR flag bit.
3) CPY $1000 :- Compare value in Y and value at given memory. So Y = $4321, $1000 has value $23, subtraction is done i.e $4321 - $23, so result is positive and no borrow at MSB and no overflow, so no flag is affected. Also result is not stored anywhere. Hence N=0, C=0, Z=0, V=0.
4) LSRD :- Logical shift right D register. D = $8765, so MSB is set to zero and LSB goes to C flag. Hence D becomes $43B2 and C=1, N=0 always, and V=0, Z=0 since no overflow and result is not zero.
5) ADCB #$EC :- Add immediate value $EC and carry to B register. So B = $65 + $EC + 1 = $152, thus B contains only $52 and N=0, C=1(since carry comming out), Z=0, V=0.
6) ROLB :- Rotate B left through carry. So MSB of B goes to C and C goes to LSB of B. B = $65 i.e 0b0110_0101, hence C=0, and B=0b1100_1011 = $CB, N=1, C=0, Z=0, V=0.
7) TSTB :- Do B - 0, C=0, V=0 is done. So B = $65 subtracting zero in this we get $65 i.e +ve, so N=0, Z=0.
Last three should be done by the student for his/her better understanding. Be feel free to ask doubt in comment, if any. Thanks
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.