meminit  or  memset

Purpose: Initialize a range of SRAM to a specific value.
Assumes: bPtrDest is valid
Passed:    R25:R24  BYTE *   bPtrStart the starting SRAM address
R22  BYTE bValue data value to write to all BYTEs in the range
R21:R20  WORD wCount number of BYTEs to initialize to bValue
Returns: R25:R24  BYTE *   bPtrStart the caller's bPtrStart value (unmodified)
Alters: No Registers, only the memory block referenced and the FLAGs
Example:  If a temporary buffer is only needed for the duration of a subroutine call, it can be allocated on the stack. Zeroing it out is needed for string functions (strlen() and strcmp(), for example) and also helps to see what changed when dumping memory while debugging.
LocalBuffer:
   CALL    AStackAlloc50         ; Allocate a temporary buffer; returns R31:R30
   MOVW    R24, R30              ; Zero the buffer to allow strcmp() to be used
   LDI     R22, 0                ;  for ASCIIz string comparisons (in addition
   LDI     R21, 0                ;  to debugging clarity)
   LDI     R20, 50               ; Specify that all 50 BYTEs be cleared
   CALL    Ameminit

;  ...                           ; Whatever else needs to be done

   CALL    AStackFree50
Notes: The bPtrStart value is 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 meminit() call:
; Passed:  R25:R24 BYTE * bPtrStart to the SRAM buffer's starting point
;              R22 BYTE   bValue to write to all BYTEs in the range
;          R21:R20 WORD   wCount is the number of BYTEs to initialize
; Returns: R25:R24 BYTE * bPtrStart, the caller's bPtrStart value (unmodified)
; Alters:  No Registers, only the memory block referenced and the FLAGs
Also see:  The memcpy and meminitEEPROM system routines.