FindFirstNumericDigit

Purpose: Search a small SRAM buffer for the first ASCII character which represents a numeric digit.
Assumes:  The buffer is limited to 255 bytes.
Passed: R25:R24  CHAR *   szPtrBuffer address of the SRAM buffer to examine
R22 BYTE   bMaxCount maximum number of BYTEs to check
Returns:   R25:R24 CHAR * szPtrFirstNum   pointer to the first ASCII '0' through '9' found within the range OR
a NULL pointer (0x0000) if none of those ASCII digits were found in the range
Alters: R26, R27, and the FLAGs
Example:  
.ORG  0x1000
   ADIW    R26, 0                 ; If R27:R26 passed is zero, no command line
   BRNE    AGoodToGo              ;  parameter was passed, so parse nothing
   RET

GoodToGo:
   MOVW    R24, R26               ; Point to the start of the buffer
   LDI     R22, 80                ; Specify an 80 BYTE limit
   CALL    AFindFirstNumericDigit
   ADIW    R24, 0                 ; Check for a NULL pointer returned
   BRNE    APrintFound
   LDI     R25, AszNotFound >> 8  ; Point to the "None found ..." string
   LDI     R24, AszNotFound & 0xFF
   JMP     APrintFLASHASCIIz      ; Print it and exit

PrintFound:
   MOVW    R30, R24               ; Save the address and set the pointer
   LD      R24, Z                 ; Retrieve the character at that address
   CALL    APrintCHAR             ; Print that first ASCII character found
   MOVW    R22, R30               ; Move the pointer (address) to R23:R22
   LDI     R25, AszFound >> 8     ; Point R25:R24 at the "Found ..." string
   LDI     R24, AszFound & 0xFF
   CALL    APrintDescAndHexWORD   ; Print the string and the WORD in R23:R22
   JMP     APrintNewLine   ;

szNotFound: .STRING  "None found in that range\n"
szFound:    .STRING  "Found at address"
Test it:
m>@ 0x1000
m>@ 0x1000    ; Comment
None found in that range
m>@ 0x1000    ; This is at the end of a comment 4
4 found at address 0x025F
m>@ 0x1000 Test string
None found in that range
m>@ 0x1000 234
2 found at address 0x023A
m>@ 0x1000        Test input 1
1 found at address 0x024C
m>                                                                              
Notes: The search is for any of the characters '0' (= ASCII 0x30 = 48) through '9' (= ASCII 0x39 = 57).
Although the usual string terminator is a BYTE of 0, this routine does not check for it, but will examine up to the limit specified.          
The strlen System Function could be used to determine the number of bytes in the string to pass as bMaxCount.
Dropin: 
(setup
code)
;   Setup for the FindFirstNumericDigit() call:
; Passed:  R25:R24 CHAR * szPtrBuffer pointer to the start of the SRAM buffer
;              R22 BYTE   bMaxCount   maximum number of BYTEs to search
; Returns: R25:R24 CHAR * szPtrFirst  pointer to the first numeric ASCII BYTE
;                                     this will be a NULL if none are found
; Alters:  R26, R27, and the FLAGs
Also see:  The parsing and PrintSRAMASCIIz System Functions.