diff --git a/avr/utils.asm b/avr/utils.asm index 61db65a..ab70c33 100644 --- a/avr/utils.asm +++ b/avr/utils.asm @@ -79,8 +79,9 @@ Utils_IncrementCounter32: ld r19, x+ ld r20, x+ ld r21, x - clr r22 - inc r18 + ldi r22, 1 + add r18, r22 + clr r22 ; doesn't affect carry flag adc r19, r22 adc r20, r22 adc r21, r22 @@ -92,6 +93,27 @@ Utils_IncrementCounter32: +; *************************************************************************** +; Increment a 16 bit counter at the address given by X. +; IN: +; - X: Address of the 2 byte counter (1. byte is LSB) +; OUT: +; - nothing +; MODIFIED REGISTERS: r18, r19, 22 + +Utils_IncrementCounter16: + ld r18, x+ + ld r19, x + ldi r22, 1 + add r18, r22 + clr r22 ; doesn't affect carry flag + adc r19, r22 + st x, r19 + st -x, r18 + ret + + + ; *************************************************************************** ; Utils_ReadEeprom