I need to add two 16 bit numbers using the instructions add and adc. The micro-controller I am using is an AtMega32 which has a max register size of 8 bits
This is what I tried so far, eg I am adding the numbers 5438 + 6098
.include "m32def.inc"
.org 0x0000
init:
ldi r16,54
ldi r17,38
ldi r18,60
ldi r19,98
start:
add r17,r19
adc r16,r18
rjmp init
If I add the lower bytes 38 and 98 = 136 which is an 8 bit number so it stores it perfectly fine with no carry but I want it to carry over so that I can add 54 and 60 with the carry to get 115. I dont know, maybe I am doing something wrong