diff --git a/kernel.asm b/kernel.asm index 3a2150a..6f0e6b9 100644 --- a/kernel.asm +++ b/kernel.asm @@ -25,6 +25,8 @@ $0000000; Cycles label KeyPressedState: $0000000; The ID of a Key Being Pressed (If Any) + label _allocator_ptr: + $000000 @ $4B0C0: @@ -52,6 +54,7 @@ data image wallpaper.png wallpaper.png data ascii quit_label QUIT data ascii jump_label JUMP data ascii diss_label DISS +data ascii alloc_label ALLOC data buffer command_line_input 64 @@ -135,6 +138,12 @@ data ascii diss_ret ret data ascii diss_unknown unknown opcode +; structure asm block +; start length +; n ptr yo bu + + + label append_num_to_string: tx $8 $4 loadi $6 7 @@ -314,6 +323,19 @@ label do_shell: add $4 $5 $4 call jump + + loadi $4 @command_line_input + loadi $5 alloc_label + loadi $6 5 + call strcmp + loadi $2 1 + jneq +6 + call shift_terminal + bzero command_line_input + loadi $4 10; + call $FFFFF0 + call append_num_to_string + ret label handle_keypress: @@ -364,9 +386,8 @@ label handle_keypress: loadi $4 label_cycles call draw_string; - loadi $4 $4B000 - loadi $2 $40 - add $2 $4 $4 + + loadi $4 _allocator_ptr call print_addr loadi $9 1; @@ -444,4 +465,18 @@ label handle_keypress: call draw_string; updsp - jmp $CB000; \ No newline at end of file + jmp $CB000; + + +; Very Very Watermark Allocator +@ $FFFFF0: + ; $4 contains a length which corresponds to number of bytes + label allocator: + load $1 _allocator_ptr + add $1 $4 $1 + store $1 _allocator_ptr + loadi $2 $FFFFF0 + sub $2 $1 $2 + sub $2 $4 $4 + + ret