# AVR Assembly - Operations with two 8-bit registers in 16-bit

R20 = (4 * R16 + 3 * R17 - R18) / 8

.org 0
start:
ldi r16, 10
ldi r17, 20
ldi r18, 10
lsl r16
lsl r16
mov r20,r17
lsl r20
sub r20,r18
asr r20
asr r20
asr r20

konec:
rjmp konec


I created this program (ATMega169), to compute the expression and for the sake of accuracy I would need the operations to be performed in 16 bits. I know that there are R26 R27 registers that "act" as one, but I have no idea how to work with it. I need some study material or some kind of advice. Thank you in advance

• study the ATmega datasheet ... there may also be a programming manual .... it is possible that there is s sequence of events to follow when dealing with 16 bit data transfers .... possibly operate on upper byte first and the lower byte on the next operation – jsotola Apr 22 at 0:38
• There’s X,Y and Z which are register pairs 26:27,28:29,30:31. Mainly for pointer (indirect addressing) use. For your math, X,Y or Z won’t help you much. – Kartman Apr 22 at 1:18
• And if I convert the registers to these x and y, then I don't get more range or any benefits? – Aaron7 Apr 22 at 1:27

The $$\x\$$ and $$\y\$$ and $$\z\$$ registers are mostly for indirect references: "These registers are 16-bit address pointers for indirect addressing of the data space." There aren't any ALU operations that support 16-bit because the ALU is an 8-bit ALU, not a 16-bit ALU. There's no escaping that requirement here.