I have my stage2 bootloader operating in unreal mode jump to my protected mode kernel. before i make the jump, however, i would like to determine how many megabytes of RAM are present. i wrote the following slice of code:
Code: Select all
checkram:
???mov???dx, 3??????;# of megabytes - assume 3 megs exist
???mov???esi, 0x3FFFFC???;top 4 bytes of the fourth megabyte of ram
???xor???ax, ax
???mov???ds, ax
checkram_loop:
???mov???ebx, [ds:esi]
???mov???dword [ds:esi], "TEST"
???mov???eax, [ds:esi]
???mov???[ds:esi], ebx???;restore mem just in case
???cmp???eax, "TEST"
???jnz???checkram_done
???add???esi, 0x100000???;go to next megabyte
???inc???dx
???jmp???checkram_loop
checkram_done:?????????;dx holds # of megabytes
???ret
i am wondering if this method of finding out how much memory exists will work correctly, and if it is possible i would be running into any reserved areas or anything... also, is 0x0FFFFC a good offset into the megabyte to use to probe?
Thanks.