| Purpose: | Alphabetically compare a character string in SRAM with one in FLASH. | ||||
| Assumes: | Both are ASCIIz (i.e., ASCII NULL-terminated) strings. | ||||
| Passed: | R25:R24 | BYTE * | szPtrSRAM | pointer to the buffer containing string in SRAM | |
| R23:R22 | BYTE * | szPtrFLASH | pointer to the 328P FLASH buffer containing the second ASCIIz string OR | ||
| R26:R23:R22 | BYTE * | szPtrFLASH | the 1284P or 2560 FLASH source address with the second ASCIIz string | ||
| Returns: | R24 | CHAR | cResult | less than 0 when String#1 alphabetically preceeds String#2 OR equal to 0 when the strings are same length and have identical BYTEs OR greater than 0 when String#1 alphabetically follows String#2 |
|
| Alters: | R25, R26, R27, R30, R31, and the FLAGs (the "T" FLAG, specifically) | ||||
| Example: |
|
| Test it: |
|
| Notes: | Less than zero means that cResult, the signed result returned in R24, is 0x80 through 0xFF (i.e., the most significant bit is set.) |
| More than zero means that cResult is 1 through 0x7F (= 127.) | |
| The comparison is case-sensitive. | |
| Dropin: (setup code) |
; Setup for the strcmpPGM() or strcmpFLASH() call:
; Passed: R25:R24 BYTE * szPtrSRAM pointer to string in SRAM
; R23:R22 BYTE * szPtrFLASH pointer to string in 328P FLASH OR
; R26:R23:R22 BYTE * szPtrFLASH pointer to string in 1284P or 2560 FLASH
; Returns: R24 CHAR < 0 if SRAM string alphabetically preceeds PGM string
; = 0 if the strings are same length and identical
; > 0 if SRAM string alphabetically follows PGM string
; Alters: R25, R26, R27, R30, R31, and the FLAGs ("T", specifically) |
| Also see: | The strcpyPGM, strlenPGM, strcmp, strchr, strcpy, and strlen System Functions. |