]> wirehaze git hosting - BOS.git/blob - kernel/realmode/mem.inc

wirehaze git hosting

0446e02ac7a70889033187fad91c6a596a6bb55c
[BOS.git] / kernel / realmode / mem.inc
1 ;----------------------------------------------------------;
2 ; BOS kernel Christoffer Bubach, 2003-2005. ;
3 ;----------------------------------------------------------;
4 ; ;
5 ; Get memory size, only using E801 right now. ;
6 ; ;
7 ;----------------------------------------------------------;
8
9 ;-----------------------------------------;
10 ; get mem ;
11 ; in: nothing ;
12 ; out: eax = mem in bytes, 0 = error ;
13 ;-----------------------------------------;
14 getmem:
15 push dx
16 push cx
17 push ebx
18
19 xor eax, eax
20 xor ebx, ebx
21 mov ax, 0xE801
22 xor dx, dx
23 xor cx, cx
24 int 0x15
25 jnc .cont1
26 xor eax, eax
27 jmp .end ; failed! :'(
28
29 .cont1:
30 mov si, ax
31 or si, bx
32 jne .cont
33 mov ax, cx
34 mov bx, dx
35
36 .cont:
37 cmp ax, 0x3C00
38 jb .below_16
39 movzx eax, bx
40 add eax, 0x100
41 shl eax, 16 ; eax = eax * 65536
42 jmp .end
43
44 .below_16:
45 shl eax, 10 ; eax = eax * 1024
46
47 .end:
48 pop ebx
49 pop cx
50 pop dx
51 ret