summaryrefslogtreecommitdiff
path: root/builtin_free.asm
blob: 96e3c86f0de57c5a51b5cc3a6766ca671ecd8811 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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