Using an Arduino, I have to write a function in Atmel AVR Assembly for my computer science class that computes the 8-bit average of two 8-bit values in assembly. I am not allowed to use any branching instructions either (but skips are fine).
This is what I have so far:
.global average
average:
add r24, r22
asr r24
ret
For the part of my program where I have to compute the average of 69 and 60, it returns -64 instead of 64. Does anyone know how I would make this function work? Any help would be much appreciated.