summaryrefslogtreecommitdiff
path: root/builtin_free.asm
diff options
context:
space:
mode:
Diffstat (limited to 'builtin_free.asm')
-rw-r--r--builtin_free.asm35
1 files changed, 35 insertions, 0 deletions
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