Hi!
================================================================
getting memory sizes
================================================================
>is here any good way to count a system's memory?
>something that might be easily portable to other architectures?
To get PC extended memory size, start with BIOS interrupts,
in this order:
- INT 15h AX=E820h (look for type 1 memory)
- INT 15h AX=E801h
- INT 15h AH=88h
Details:
If none of those work, read extended memory size from CMOS
; get extended memory size from CMOS -- won't
; report more than 63.999 meg (65535/1024)
mov al,18h
out 70h,al
in al,71h
mov ah,al
mov al,17h
out 70h,al
in al,71h
mov [ext_mem_size],ax ; in K
Direct probing is fraught with problems:
- Address "aliasing" caused by unconnected high-order address
lines. I have a 486 system in which addresses 64 meg, 128 meg,
192 meg, etc. "wrap around" to address 0.
- Memory mapped hardware that causes the computer to freeze
when your memory probe steps on it.
- PC might have a bizarre and unique method of turning on the
A20 gate; a method not supported by your direct probing code.
- C memory probing code that does not use 'volatile', or buggy
compiler (Borland C++ 3.1) for which 'volatile' does not work
- Bus float causes the memory test to succeed even if there's
no memory