strlenEEPROM

Purpose: Determine the number of BYTEs in a string in EEPROM.
Assumes:  Strings in EEPROM can be terminated with a BYTE of 0, 0xFE, or 0xFF.
Passed:     R25:R24  BYTE *   bPtrEEPROM  pointer to the EEPROM address at which to begin
Returns: R25:R24  WORD wCount the BYTE count, which may be zero.
FLAGS  ZERO flag set (TRUE) when length is zero (and R25:R24 = 0) OR
clear (FALSE) when length is > 0 (and R25:R24 > 0)
Alters: Only R24, R25 and the FLAGs
Example: 
.ORG  0x1000

CheckEELength:
   ADIW    R26, 0                ; If 'X' is zero, no parameter was passed on
   BREQ    ACheckEELength_Ret    ;  the command line, so just exit immediately
   MOVW    R24, R26              ; Point R25:R24 at buffer to be parsed
   CALL    AParseValue           ; Extract one numeric value from the string
   SBRS    R21, BIT_PV_VALID     ; If no value was parsed, just exit
   RJMP    ACheckEELength_Ret    ; The ULONG value returned in R25:R24:R23:R22

   MOVW    R24, R22              ; The EEPROM pointer is the Low WORD of that
   CALL    AstrlenEEPROM         ; The System Function being demonstrated
   CALL    ADumpRegisters        ; Optional (for FLAGs); toggle on with '}'
   CALL    APrintWORD            ; Print the WORD returned in R25:R24
   LDI     R25, ACSZ_BYTEs >> 8
   LDI     R24, ACSZ_BYTEs & 0xFF
   CALL    APrintFLASHASCIIz     ; The string below, ending in CR, LF

CheckEELength_Ret:
   RET

CSZ_BYTEs:  .STRING  " BYTEs in the EEPROM string\n"
Test it:
m>DE+ 80 240
EEPROM contents:
0050:  6E 52 46 20 50 54 58 20-63 6F 6E 66 69 67 3A 00  nRF PTX config:.
0060:  7C 3F 3F 03 34 4E 06 31-44 65 6D 6F 32 44 65 6D  |??.4N.1Demo2Dem
0070:  6F 33 34 35 36 31 44 65-6D 6F 3F 07 88 D0 07 00  o34561Demo?.....
0080:  6E 52 46 20 50 52 58 20-63 6F 6E 66 69 67 3A 00  nRF PRX config:.
0090:  7D 00 3F 03 34 4E 06 31-44 65 6D 6F 32 44 65 6D  }.?.4N.1Demo2Dem
00A0:  6F 33 34 35 36 31 44 65-6D 6F 3F 07 88 D0 07 00  o34561Demo?.....
00B0:  3B 20 42 6F 6F 74 75 70-20 49 6E 69 74 3A 20 00  ; Bootup Init: .
00C0:  45 20 31 20 7E 3D 20 30-78 43 30 00 4E 2A 2A 00  E 1 ~= 0xC0.N**.
00D0:  4E 44 2B 00 45 53 20 34-37 39 3D 35 38 00 45 20  ND+.ES 479=58.E
00E0:  30 78 31 39 20 3D 20 30-78 32 35 00 45 20 30 78  0x19 = 0x25.E 0x
00F0:  32 30 20 3D 20 30 78 32-34 00 FF FF FF FF FF FF  20 = 0x24.......
0100:  45 00 57 01 30 78 35 30-30 20 3D 20 32 20 53 00  E.W.0x500 = 2 S.
0110:  54 53 32 20 30 78 35 30-30 00 45 53 57 20 30 78  TS2 0x500.ESW 0x
0120:  35 31 30 20 3D 20 31 20-53 00 00 64 73 20 30 20  510 = 1 S..ds 0
0130:  34 30 00 FF FF FF FF FF-FF FF FF FF FF FF FF FF  40..............
m>@ 0x1000 80
15 BYTEs in the EEPROM string
m>@ 0x1000 0xb0
15 BYTEs in the EEPROM string
m>@ 4096 0xc0
11 BYTEs in the EEPROM string
m>@ 4096 0xCC
3 BYTEs in the EEPROM string
m>@ 4096 0xCF
0 BYTEs in the EEPROM string
m>@ 4096 0xF0
9 BYTEs in the EEPROM string
m>@ 4096 0x130
2 BYTEs in the EEPROM string
m>@ 4096 0x138
0 BYTEs in the EEPROM string
m>                                                                              
Notes: Strings in EEPROM are considered terminated if they end in 0, 0xFE or 0xFF, since 0xFF is the unprogrammed value.
The string may begin with a NULL, 0xFE, or 0xFF, which are all valid and will return zero length.
EEPROM addresses beyond the end of EEPROM (i.e., 0x400 or greater) will readback as 0xFF.
The ZERO flag has already been set or cleared, so no comparison of R25:R24 need be done.
Dropin: 
(setup
code)
;   Setup for the strlenEEPROM() call:
; Passed:  R25:R24 BYTE * bPtrEEPROM EEPROM address at which to begin counting            
; Returns: R25:R24 WORD   wCount, number of BYTEs before the terminator
;  (Also:)    ZERO FLAG   set (TRUE) when length is zero (and R25:R24 = 0)
;                         clear (FALSE) when length is > 0 (and R25:R24 > 0)
; Alters:  Only R24, R25, and the FLAGSs
; Notes:   The terminator BYTE is 0, 0xFE, or 0xFF for EEPROM strings.
Also see:  The strcpy, strlen, and strlenPGM System Functions.