neon wrote:
You can use
int 15h function 2403h and
int 15h function 2402h to check for A20. Modern systems should support these.
You don't have to use 0 and 1MB. Testing using the boot loader signature (as was suggested above) and compare address 0:7dfe with ffff:7e0e, if they are the same, then you know A20 is not enabled. This is the safest route.
An even safer route would involve using VM86 mode.
What we would do is to launch a V86-mode task that is different than the main task.Then we can test the INT 15h functions 2402h and 2403h.
In some ancient 386DX machines, these functions, as well as the functions to retrieve the motherboard's memory map, make the whole system crash. I don't know if there are laptops or pocket x86 PCs that could fail in similar ways.
So, with a V86 task, these functions will either have no effect, crash the whole system (in this case only crash the V86 task), or succeed.In any case, if they fail to enable the A20 or to retrieve the memory map, we will be able to terminate the secondary V86 task even if it's crashed, and we will have the chance to test an alternate method without failing.
But this is already a system prepared to run in widely nonstandard hardware. I guess it's always good to eventually add that support as long as you really need it in practice, so you can understand how it really works closely.