Examine the program in Figure 2. This solution solves the first problem by using
ID: 3819218 • Letter: E
Question
Examine the program in Figure 2. This solution solves the first problem by using the double accumulator (D) to maintain the running sum in 2 Bytes. What is the maximum unsigned sum in 2 bytes?: The second is solved by the indexed addressing mode (ie, adding to D the contents of Byte locations pointed to by within a program loop. Note the compare instruction after x is incremented, used to determine whether the Looping has completed. Why do we compare X with $210B (one location beyond the last element in the array), instead of comparing with the address of the last byte of the array? Explain why this is necessary using the given program. Also describe how the program (byte) length of Figure 2 compares with the length of the Step 2 program. MNEMONIC COMMENTS HEX CONTENTS ADDRESS CLRA Clear A to all zeros j 2000 Clear B to zeros (therefore D as well) CLRB 2001 LDX #$2101 Point X to first number 2002 Add to D a number from the list ADDD 0,X 2005 2 byte placeholder does nothing. Will be BRN 2007 2007 used in step 8. Advance X to point to next number INX 2009 200A Rt 1 CPX #$210B Done yet? and repeat if not 200D BNE $2005 Branch back Else stop SWI 200F re 2. Array Addition Ising Indeyed AddressingExplanation / Answer
The maximum Unsigned sum using 2 bytes means that there is no overflow condition, the value is 7FFF.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.