avr: added Heap_AllocAndZero

This commit is contained in:
Martin Preuss
2026-04-20 23:59:46 +02:00
parent ea286e68ce
commit 0eeff3634c

View File

@@ -86,6 +86,39 @@ Heap_Alloc:
; ---------------------------------------------------------------------------
; @routine Heap_AllocAndZero
;
; Allocates data on the heap and presets all bytes with zero.
;
; @param r25:r24 number of bytes to alloc
; @return CFLAG set of okay, cleared otherwise
; @return X start of allocated memory
; @clobbers r16, r17, r18, r19, r24, r25, X
Heap_AllocAndZero:
push r24
push r25
rcall heapAllocFirstFit
pop r25
pop r24
brcc Heap_AllocAndZero_ret
push xl
push xh
clr r18
Heap_AllocAndZero_loop:
st X+, r18
sbiw r25:r24, 1
brne Heap_AllocAndZero_loop
pop xh
pop xl
sec
Heap_AllocAndZero_ret:
ret
; @end
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine heapAllocFirstFit ; @routine heapAllocFirstFit