Files
aqhomecontrol/avr/common/inccounter16.asm
2026-04-20 23:56:52 +02:00

48 lines
1.1 KiB
NASM

; ***************************************************************************
; copyright : (C) 2026 by Martin Preuss
; email : martin@libchipcard.de
;
; ***************************************************************************
; * This file is part of the project "AqHome". *
; * Please see toplevel file COPYING of that project for license details. *
; ***************************************************************************
#ifndef AQH_AVR_COMMON_INCCOUNTER16_ASM
#define AQH_AVR_COMMON_INCCOUNTER16_ASM
; ***************************************************************************
; code
.cseg
; ---------------------------------------------------------------------------
; @routine Utils_IncrementCounter16 @global
;
; Increment a 16 bit counter at the address given by X.
;
; @param X Address of the 2 byte counter (1. byte is LSB)
; @clobbers r18, r19, r22
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
; @end
#endif