This commit is contained in:
Nero 2019-03-13 17:27:52 +00:00
parent 271ee98e27
commit b21acb076c

36
mem.asm
View File

@ -14,7 +14,9 @@ mtab_ref:
ret ret
; finds a place for a new item in the mm table ; finds a place for a new item in the mm table
; out: bx ; this detects 'empty' slots by the size field being zero
; in: ds:si: pointer to first mtab item
; out: bx: offset for empty slot
mtab_alloc: mtab_alloc:
push ax push ax
call mtab_ref call mtab_ref
@ -27,6 +29,38 @@ mtab_alloc:
pop ax pop ax
ret ret
; splits a mtab item at offset
; in: ds:si: pointer mtab item
; ax: split position in 16 byte blocks
; out: ds:si: pointer to lower half
; ds:di: pointer to upper half
mtab_split:
push cx ; remaining memory block length
mov cx,[ds:si]
mov [ds:si],ax ; this resizes the first item
sub cx, ax
push bx
call mtab_alloc
mov di,bx
pop bx
push si ; backup because movsw increments them
push di ; ^
push cx ; counter for movsb
mov es,ds
mov cx,0x08 ; 8 words = 16 bytes
rep movsw ; repeat cx times
pop cx
pop di
pop si
mov [ds:di],cx
pop cx
ret
; in: ax: segment ; in: ax: segment
; bh: task id (0 for non-task memory) ; bh: task id (0 for non-task memory)
; bl: memory type (see enum at top of file) ; bl: memory type (see enum at top of file)