From 857e35883611f4cb1abadc3c35256cf6f31d8864 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 29 Jan 2023 18:50:41 +0100 Subject: [PATCH] Utils: Dixed Utils_IncrementCounter32, added Utils_IncrementCounter16. --- avr/utils.asm | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) 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