Remove LISP attempts
This commit is contained in:
parent
0622188353
commit
4631808a63
@ -1,32 +0,0 @@
|
||||
; All ptrs in ds segment, pointing to a node as returned by malloc
|
||||
|
||||
; in ax ptr car
|
||||
; bx ptr cdr
|
||||
; out di ptr con
|
||||
cons:
|
||||
push cx ; length for malloc
|
||||
push dx
|
||||
mov cx,4
|
||||
mov dl,0x01 ; type for cons
|
||||
call malloc
|
||||
pop dx
|
||||
pop cx
|
||||
mov word [di+0x04],ax
|
||||
mov word [di+0x06],bx
|
||||
ret
|
||||
|
||||
; in ax ptr con
|
||||
; out di ptr car
|
||||
car:
|
||||
mov si,ax
|
||||
; TODO: type check
|
||||
mov di,[si+0x04]
|
||||
ret
|
||||
|
||||
; in ax ptr con
|
||||
; out di ptr cdr
|
||||
cdr:
|
||||
mov si,ax
|
||||
; TODO: type check
|
||||
mov di,[si+0x06]
|
||||
ret
|
@ -1,58 +0,0 @@
|
||||
verbose_malloc:
|
||||
call malloc
|
||||
push si ; both backup and input value for kprintf
|
||||
mov si,.fmt
|
||||
push di
|
||||
call kprintf
|
||||
pop di
|
||||
pop si
|
||||
ret
|
||||
.fmt:
|
||||
db "malloc %X", 0
|
||||
|
||||
; Allocates memory on the kernel heap
|
||||
; Strategy: smallest fit
|
||||
; in cx size in bytes
|
||||
; dl node type
|
||||
; out ds:di pointer
|
||||
;
|
||||
; Header:
|
||||
; word ptr to next item (this implies its size)
|
||||
; byte 00 = free, >0 used (refcount)
|
||||
; byte high-level type
|
||||
malloc:
|
||||
push ax
|
||||
push bx
|
||||
mov di,heap
|
||||
add cx, 0x04 ; header length
|
||||
jmp .check
|
||||
.next:
|
||||
add di,[di]
|
||||
.check:
|
||||
mov ax,[di]
|
||||
test ax,0xFFFF
|
||||
jz .append ; we are on last entry
|
||||
cmp byte [di+2],0x00
|
||||
jne .next ; entry is in use
|
||||
sub ax,cx
|
||||
je .reuse ; entry has exact length
|
||||
jc .next ; entry too short
|
||||
jmp .next ; we'd have to split, not implemented yet
|
||||
.reuse: ; exact length
|
||||
mov byte [di+2],0xFF
|
||||
jmp .end
|
||||
.append: ; append to last item
|
||||
mov word [di], cx
|
||||
mov byte [di+2], 0x00
|
||||
mov byte [di+3], dl
|
||||
push di
|
||||
add word di, [di]
|
||||
mov byte [di],0x0000
|
||||
pop di
|
||||
.end:
|
||||
pop bx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
; Deallocates memory on the kernel heap
|
||||
free:
|
@ -1,9 +0,0 @@
|
||||
; Create a integer atom from a string describing said integer
|
||||
; in ds:si pointer to function arguments
|
||||
; ds:di pointer to integer atom
|
||||
int:
|
||||
sub sp, 0x30
|
||||
mov bp, sp ; buffer for integer
|
||||
|
||||
add sp, 0x30
|
||||
ret
|
@ -1,25 +0,0 @@
|
||||
; dump contents of a node to screen
|
||||
; in si
|
||||
print:
|
||||
push si ; byte iterator
|
||||
push cx ; position of next item
|
||||
push ax ; al is byte value
|
||||
mov word cx, [si] ; fetch position of next item
|
||||
cmp cx, 0x40
|
||||
jng .loop
|
||||
mov cx, 0x40
|
||||
.loop:
|
||||
lodsb
|
||||
call kprint8
|
||||
mov al, 0x20
|
||||
call kputc
|
||||
loopnz .loop
|
||||
|
||||
mov al, 0x0A
|
||||
call kputc
|
||||
mov al, 0x0D
|
||||
call kputc
|
||||
pop ax
|
||||
pop cx
|
||||
pop si
|
||||
ret
|
Loading…
Reference in New Issue
Block a user