Add Two 16-bit Numbers

Easy Assembly Math Asked at Microchip
Solve this problem

Add two 16-bit numbers on an 8-bit AVR core, where the addition has to be done a byte at a time with an explicit carry.

Constraints

  • Operands are in r24:r25 and r22:r23.
  • Result goes in r24:r25.
  • Use ADD for the low byte and ADC for the high byte.
  • Do not use any 16-bit instruction such as ADIW.
  • Preserve all other registers.
  • Return with RET.
Starter codeAssembly
1; AVR: add r22:r23 to r24:r252add16:3    ; TODO4    ret