Detecting Memory (x86): Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Combuster (talk | contribs)
Put back the old code after reading RBIL on the matter.
Undo revision 18311 by Combuster (talk)
Line 31: Line 31:


Usage:
Usage:
<source lang="asm">
<source lang="asm">
; Nullify the A-register.
xor ax, ax

; Switch to the BIOS (= request low memory size).
; Switch to the BIOS (= request low memory size).
int 0x12
int 0x12
; The carry flag is set, it failed.
; AX = amount of continuous memory in KB starting from 0.
jc .Error
; Test the A-register with itself.
test ax, ax
; The zero flag is set, it failed.
jz .Error


; AX = amount of continuous memory in kB starting from 0.
; AX = amount of continuous memory in KB starting from 0.
</source>
</source>

Note: this function always works and may not modify the carry flag, so the contents of AX should be trusted and CF should be ignored.


Alternately, you can just use INT 0x15, EAX = 0xE820 (see below).
Alternately, you can just use INT 0x15, EAX = 0xE820 (see below).