memcpyEEPROM

Purpose: Copy a block of data from EEPROM to a buffer in SRAM.
Assumes:  bPtrTo and bPtrFrom are valid.
Passed:     R25:R24  BYTE *   bPtrTo the SRAM destination address
R23:R22  BYTE *   bPtrFrom the EEPROM source address
R21:R20  WORD wCount number of BYTEs to copy
Returns: R25:R24  BYTE *   bPtrStart the caller's bPtrTo value (unmodified)
R23  BYTE bLast the data value of the last BYTE copied
Alters: R26, R27, R30, R31, the FLAGs, and the memory block referenced.
Example: 
.ORG 0x1000

SRAM_Dest = 0x600
EE_Source = 0xB0
BYTECount = 80

EEtoSRAMTest:
   LDI     R25, SRAM_Dest >> 8
   LDI     R24, SRAM_Dest & 0xFF   ; R25:R24 = target address: copy to SRAM
   LDI     R23, EE_Source >> 8
   LDI     R22, EE_Source & 0xFF   ; R23:R22 = source address; copy from EEPROM
   LDI     R21, BYTECount >> 8
   LDI     R20, BYTECount & 0xFF   ; R21:R20 = number of bytes to copy
   JMP     AmemcpyEEPROM
Test it:
>DR+ 0x600 80
SRAM contents:
0600:  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
0610:  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
0620:  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
0630:  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
0640:  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
>   ; Login to edit PROGRAM memory and use indirect call (the "@")
m>:1010000096E080E070E060EB50E040E50C94283022
m>:00000001FF
m>@ 0x1000
m>d+r 0x600 80
SRAM contents:
0600:  3B 20 42 6F 6F 74 75 70-20 49 6E 69 74 3A 20 00  ; Bootup Init: .
0610:  45 20 31 20 7E 3D 20 30-78 43 30 00 4E 2A 2A 00  E 1 ~= 0xC0.N**.
0620:  4E 44 2B 00 45 53 20 34-37 39 3D 35 38 00 45 20  ND+.ES 479=58.E
0630:  30 78 31 39 20 3D 20 30-78 32 35 00 45 20 30 78  0x19 = 0x25.E 0x
0640:  32 30 20 3D 20 30 78 32-34 00 FF FF FF FF FF FF  20 = 0x24.......
m>                                                                              
Notes: The bPtrTo and bPtrFrom values are not checked for validity.
The wCount value is limited to 2,047 (= 0x7FF) BYTEs.
If wCount is zero, it exits immediately with no SRAM change.
Dropin: 
(setup
code)
;   Setup for the memcpyEEPROM() call:
; Passed:  R25:R24 BYTE * bPtrTo   pointer to the SRAM destination buffer
;          R23:R22 BYTE * bPtrFrom pointer to the EEPROM source buffer
;          R21:R20 WORD   wCount   number of BYTEs to copy
; Returns: R25:R24 BYTE * bPtrTo   the caller's bPtrTo value (unmodified)
;  (Also):     R23 BYTE   bLast    the data value of the last BYTE copied
; Alters:  R26, R27, R30, R31, the FLAGs, and the memory block referenced
Also see:  The memcpySRAMtoEEPROM, memcpyEEPROMtoEEPROM, and memcpy System Functions and the EI (in Edit) System Command.