avr: added EepromTlv_FindNext

This commit is contained in:
Martin Preuss
2026-04-27 19:16:26 +02:00
parent 606404095e
commit 3b7317bb0f

View File

@@ -79,6 +79,34 @@ EepromTlv_FindFirst:
; ---------------------------------------------------------------------------
; @routine EepromTlv_FindNext @global
;
; Find next matching TLV
;
; @param r16 TLV type to find
; @param X points to current TLV data (will be skipped when searching)
; @return CFLAG set if TLV found, cleared otherwise
; @return r16 type
; @return r17 length
; @return X points to begin of TLV data
; @clobbers r16, r17, r18
EepromTlv_FindNext:
; skip current TLV
rcall EepromTlv_ReadHeader ; r16=type, r17=len (none), X=data
brcc EepromTlv_FindNext_ret
add xl, r17 ; skip TLV data
adc xh, r17
sub xh, r17
; begin search with next tlv
rcall eepromTlvFind ; (R18)
EepromTlv_FindNext_ret:
ret
; @end
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine eepromTlvFind @global ; @routine eepromTlvFind @global
; ;
@@ -93,7 +121,7 @@ EepromTlv_FindFirst:
eepromTlvFind: eepromTlvFind:
mov r18, r16 mov r18, r16
eepromTlvFind_loop: eepromTlvFind_loop:
rcall EepromTlv_ReadHeader ; r16=type, r17=len (none) rcall EepromTlv_ReadHeader ; r16=type, r17=len (none), X=data
brcc eepromTlvFind_notFound brcc eepromTlvFind_notFound
cp r16, r18 ; the one we wanted? cp r16, r18 ; the one we wanted?
breq eepromTlvFind_found breq eepromTlvFind_found