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

Add two 16-numbers stored in Dat1:Dat1+1 and Dat2:Data2+1 using the 8-bit additi

ID: 3679780 • Letter: A

Question

Add two 16-numbers stored in Dat1:Dat1+1 and Dat2:Data2+1 using the 8-bit addition instructions. The result is to be stored in Data3: Data3+1. Do this using add-with-carry to demonstrate the algorithm used for multiple-byte arithmetic. Use HCS12 style Add two 16-numbers stored in Dat1:Dat1+1 and Dat2:Data2+1 using the 8-bit addition instructions. The result is to be stored in Data3: Data3+1. Do this using add-with-carry to demonstrate the algorithm used for multiple-byte arithmetic. Use HCS12 style

Explanation / Answer

org 0              ;tells the assembler to start at address $0000 (RAM)

Dat1   Dat1+1   86   ;tells assembler to define 1st address
              ;Page Zero of memory
Dat2   Dat2+1   5F    ;define 2nd address
Dat3   Dat3+1    ;Store result

   LDAB 0,X            ; load Accumulator B with the first number
   INX   ; increment X to point at the second location
   ADDB 0,X    ; add the second number to the contents of Acc. B
   INX      ; increment X to point at the Sum location
   STAB 0,X    ; store the result
Loop   BRA Loop ; loop forever

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote