i am trying to read the memory map using "int 15h" but every time that the int instruction is being executed, my OS crashes.
can anyone help me with this?
the crashing always happens when i use the int instruction in real mode before setting the IDT.
for example:
Code: Select all
_start: ;this is the point where my code starts executing
mov esp, _temp_stack ;setup temp stack
jmp detect_ram ;Get mem map ----->CRASH<-----
cli
extern install ;the function for setting up GDT, IDT, Pmode, ...
call install
ret
extern mmap ;the data structure for ram entries
extern ent_cnt ;the number of entries
global detect_ram
detect_ram:
xor ebx, ebx
xor bp, bp
mov edx, 0x534D4150
mov eax, 0xe820
mov ecx, 24
mov di, [mmap]
mov [es:di + 20], dword 1
int 15h ; ------------------------------> THE SYSTEM CRASHES HERE
jc short .failed
mov edx, 0x0534D4150
cmp eax, edx
jne short .failed
test ebx, ebx
je short .failed
jmp short .jmpin
.e820lp:
mov eax, 0xe820
mov [es:di + 20], dword 1
mov ecx, 24
int 15h
jc short .e820f
mov edx, 0x0534D4150
.jmpin:
jcxz .skipent
cmp cl, 20
jbe short .notext
test byte [es:di + 20], 1
je short .skipent
.notext:
mov ecx, [es:di + 8]
or ecx, [es:di + 12]
jz .skipent
inc bp
add di, 24
.skipent:
test ebx, ebx
jne short .e820lp
.e820f:
mov [ent_cnt], bp
clc
ret
.failed:
stc
ret