diff --git a/avr/common/eeprom_tlv.asm b/avr/common/eeprom_tlv.asm index a235b53..8e86c96 100644 --- a/avr/common/eeprom_tlv.asm +++ b/avr/common/eeprom_tlv.asm @@ -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 ; @@ -93,7 +121,7 @@ EepromTlv_FindFirst: eepromTlvFind: mov r18, r16 eepromTlvFind_loop: - rcall EepromTlv_ReadHeader ; r16=type, r17=len (none) + rcall EepromTlv_ReadHeader ; r16=type, r17=len (none), X=data brcc eepromTlvFind_notFound cp r16, r18 ; the one we wanted? breq eepromTlvFind_found