From 3b46e7ef1f4c3f364e75e780eff923ef146ee42c Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sat, 23 Jun 2018 15:12:55 -0400 Subject: Implement initial builtin commands --- builtin_free.asm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 builtin_free.asm (limited to 'builtin_free.asm') diff --git a/builtin_free.asm b/builtin_free.asm new file mode 100644 index 0000000..96e3c86 --- /dev/null +++ b/builtin_free.asm @@ -0,0 +1,35 @@ +%ifndef _BUILTIN_FREE_ASM +%define _BUILTIN_FREE_ASM + +builtin_free: + push bp + mov bp, sp + + mov cx, word [bp + 4] ; argc + mov bx, word [bp + 6] ; argv + + ;cmp cx, 0 ; if no arguments, return + ;jbe .return + + mov ah, 88h ; get extended memory size + int 15h + mov dx, ax + + int 12h ; get conventional memory size + ; but it's pretty much bogus + + push dx + push ax + push .msg_fmt + call printf + add sp, 2 * 2 + add bx, 2 + + .return: + mov sp, bp + pop bp + ret + .msg_fmt db 'Conventional memory: %dK\n' + db 'Extended memory: %dK', 0 + +%endif -- cgit