Purpose: | Determine the number of BYTEs in an ASCIIz string in SRAM. | |||
Assumes: | The string is between 0 and 2,048 BYTEs in length (which is all available SRAM in a 328P). | |||
Passed: | R25:R24 | CHAR * | szBuffer | pointer to the SRAM buffer to examine |
Returns: | R25:R24 | WORD | wCount | the BYTE count in the ASCIIz string, 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: |
|
Test it: |
|
Notes: | An ASCIIz string is a series of printable characters, the end of which is defined by a NULL (= 0) BYTE. |
The string may begin with a NULL, which is valid and will return zero length. The ZERO flag has already been set or cleared, so no comparison is needed. | |
Dropin: (setup code) |
; Setup for the strlen() call: ; Passed: R25:R24 CHAR * szBuffer pointer to the SRAM buffer to check ; Returns: R25:R24 WORD wCount, number of BYTEs before the first NULL BYTE ; (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 FLAGs |
Also see: | The strcpy, strlenEEPROM, and strlenPGM System Functions. |