diff --git a/avr/modules/heap/main.asm b/avr/modules/heap/main.asm index fa9fadd..a3938ac 100644 --- a/avr/modules/heap/main.asm +++ b/avr/modules/heap/main.asm @@ -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