Detecting Memory (x86): Difference between revisions

m
set register di to 0x8004 so the BIOS code located in es:0 will not be overwritten by int 15
[unchecked revision][unchecked revision]
No edit summary
m (set register di to 0x8004 so the BIOS code located in es:0 will not be overwritten by int 15)
Line 372:
<source lang="asm">
; use the INT 0x15, eax= 0xE820 BIOS function to get a memory map
; note: initially di is 0, set it to a value so that the BIOS code will not be overwritten. The consequence of overwriting the BIOS code will lead to problems like getting stuck in `int 0x15`
; inputs: es:di -> destination buffer for 24 byte entries
; outputs: bp = entry count, trashes all registers except esi
mmap_ent equ 0x8000 ; the number of entries will be stored at 0x8000
do_e820:
mov di, 0x8004 ; Set di to 0x8004. Otherwise this code will get stuck in `int 0x15` after some entries are fetched
xor ebx, ebx ; ebx must be 0 to start
xor bp, bp ; keep an entry count in bp
Anonymous user