diff --git a/heap.asm b/heap.asm index 9035b6a..f92e978 100644 --- a/heap.asm +++ b/heap.asm @@ -15,7 +15,7 @@ verbose_malloc: ; ; Header: ; word ptr to next item (this implies its size) -; byte 00 = free, FF = in use +; byte 00 = free, >0 used (refcount) malloc: push ax mov si,heap @@ -31,12 +31,10 @@ malloc: sub ax,cx je .reuse ; entry has exact length jc .next ; entry too short - jmp .next ; we'd have to split + jmp .next ; we'd have to split, not implemented yet .reuse: ; exact length mov byte [si+2],0xFF - add si, 0x03 - pop ax - ret + jmp .end .append: ; append to last item mov ax, si add ax, 3 @@ -47,6 +45,7 @@ malloc: mov word si,[si] mov byte [si],0x0000 pop si +.end: add si, 0x03 pop ax ret