29 lines
433 B
NASM
29 lines
433 B
NASM
|
heap_size:
|
||
|
dw 0x0100
|
||
|
|
||
|
heap_init:
|
||
|
push ax ; byte value (0)
|
||
|
push cx ; loop counter
|
||
|
push di ; target ptr
|
||
|
xor ax, ax
|
||
|
mov cx, [heap_size]
|
||
|
mov di, heap
|
||
|
rep stosb ; rep makes this loop cx times, incrementing di, writing al
|
||
|
pop di
|
||
|
pop cx
|
||
|
pop ax
|
||
|
ret
|
||
|
|
||
|
; in ax number of bytes to alloc
|
||
|
; out ds:di
|
||
|
malloc:
|
||
|
push dx ; length of block index
|
||
|
or ax,0x0F
|
||
|
inc ax
|
||
|
mov dx, 0x100
|
||
|
mov bp, heap
|
||
|
|
||
|
int 0x2E
|
||
|
pop dx
|
||
|
ret
|