ReadEEPROM_BYTE,  ReadEEPROM_WORD,  and  ReadEEPROM_ULONG

Purpose: Read one (1), two (2), or four (4) successive BYTEs from EEPROM.
Assumes:  BYTEs in EEPROM are read from Least Significant to Most Significant.
The address specified is valid.
Passed:     R25:R24 VOID *  vPtrEEPROM  address of the EEPROM first or only BYTE to read
Returns: R24 BYTEbValue the BYTE at that EEPROM address (OR)
R25:R24 WORDwValue the WORD at that EEPROM address (OR)
R25:R24:R23:R22 ULONGulValue the ULONG at that EEPROM address
Alters: Only the return value Registers and the FLAGs
Example: 
   .ORG  0x1000

EEReads:
   MOVW    R24, R26              ; Copy the pointer to the address
   CALL    AParseValue
   MOVW    R30, R22              ; Returns R25:R24:R23:R22; save only LowWORD
   SBRS    R21, BIT_PV_VALID
   RET                           ; Exit if no value was found

   MOVW    R24, R30              ; The saved address parsed above
   CALL    AReadEEPROM_BYTE      ; Returns the EEPROM BYTE in R24
   MOV     R22, R24              ; Transfer the EEPROM BYTE returned to R22
   LDI     R25, ACSZ_BYTE >> 8   ; Point to the first string
   LDI     R24, ACSZ_BYTE & 0xFF
   LDI     R19, '='              ; Specify the intermediate character
   CALL    APrintDescAndHexBYTE  ; Print description string, 0x and BYTE value

   MOVW    R24, R30              ; Same beginning address as before
   CALL    AReadEEPROM_WORD      ; This time read two (2) BYTEs
   MOVW    R22, R24
   LDI     R25, ACSZ_WORD >> 8
   LDI     R24, ACSZ_WORD & 0xFF
   CALL    APrintDescAndHexWORD
   LDI     R25, ACSZ_ULONG >> 8  ; This one is done differently since there is
   LDI     R24, ACSZ_ULONG & 0xFF;  no PrintDescAndHexULONG() function
   CALL    APrintFLASHASCIIz
   MOVW    R24, R30              ; Same beginning address as the others
   CALL    AReadEEPROM_ULONG
;- MOVW    R20, R26              ; Point to the parsing buffer  (OR)
   LDI     R21, 0                ; Set the FormatULONGHex copy destination to
   LDI     R20, 0                ;  a NULL pointer to skip copying it anywhere
   LDI     R18, 1 << BIT_FMT_PRINT ;
   CALL    AFormatULONGHex       ; Format and print the value in R25:R24:R23:R22
   JMP     APrintNewLine

CSZ_BYTE:  .STRING  "EEPROM BYTE at that address"
CSZ_WORD:  .STRING  "; WORD"
CSZ_ULONG: .STRING  "; ULONG = 0x"
Test it:
m>DE+ 0 16
EEPROM contents:
0000:  10 21 00 9F 01 00 84 FF-04 00 FF FF 28 3C 50 FF  .!..........(.P.
m>@ 0x1000 0
EEPROM BYTE at that address = 0x10; WORD = 0x2110; ULONG = 0x9F002110
m>@ 0x1000 1
EEPROM BYTE at that address = 0x21; WORD = 0x0021; ULONG = 0x19F0021
m>@  0x1000  2
EEPROM BYTE at that address = 0x00; WORD = 0x9F00; ULONG = 0x19F00
m>@ 0x1000  3
EEPROM BYTE at that address = 0x9F; WORD = 0x019F; ULONG = 0x8400019F
m>@ 0x1000 4
EEPROM BYTE at that address = 0x01; WORD = 0x0001; ULONG = 0xFF840001
m>dE+ 0x3F8
m>@ 0x1000 0x3FB
EEPROM BYTE at that address = 0xFF; WORD = 0xFFFF; ULONG = 0x1FFFFFF
m>@ 0x1000  0x3FC
EEPROM BYTE at that address = 0xFF; WORD = 0xFFFF; ULONG = 0xFF01FFFF
m>@ 0x1000 0x3FD
EEPROM BYTE at that address = 0xFF; WORD = 0x01FF; ULONG = 0xFFFF01FF
m>@ 0x1000  0x3fe
EEPROM BYTE at that address = 0x01; WORD = 0xFF01; ULONG = 0xFFFFFF01
m>@ 0x1000   0x3ff
EEPROM BYTE at that address = 0xFF; WORD = 0xFFFF; ULONG = 0xFFFFFFFF
m>                                                                              
Notes: Specifying an address past the end of physical EEPROM space always returns 0xFF.
Dropin: 
(setup
code)
;   Setup for the ReadEEPROM_*() call:
; Passed:          R25:R24 VOID * vPtrEE address from which to begin reading                
; Returns:             R24 BYTE   bValue the BYTE at that address
;                  R25:R24 WORD   wValue the WORD at that address
;          R25:R24:R23:R22 ULONG  ulValue the ULONG at that address
; Alters:  Only the Registers returned and the FLAGSs
Also see:  The WriteEEPROM_BYTE, WriteEEPROM_WORD, and WriteEEPROM_ULONG System Functions.