Question about the A20 line
I've hit a snag when testing my code on various different pc's, in which
the a20 enabling code works on about 60% of systems i try, and others
fail..
i've looked at a few examples of code that enables the a20, in other
peoples work..
I found something rather new to me in code written by thomas pytel (author
of pmode/w and numerous other pmode386 systems), the same piece
of code also appears in narech kumar's dos32a dos extender,
could someone explain to me how exactly this code is seeing if
the a20 is enabled and why this method works???
thanks, alex
=========== code follows
enablea20test: ; test for enabled A20
push fs gs
xor ax,ax ; set A20 test segments 0 and 0ffffh
mov fs,ax
dec ax
mov gs,ax
mov al,fs:[0000h] ; get byte from 0:0
mov ah,al ; preserve old byte
not al ; modify byte
xchg al,gs:[0010h] ; put modified byte to 0ffffh:10h
cmp ah,fs:[0000h] ; set zero if byte at 0:0 not modified
mov gs:[0010h],al ; put back old byte at 0ffffh:10h
pop gs fs
ret ; return, zero if A20 enabled
disablea20test: ; test for disabled A20
push ds esi edi
mov ds,cs:selzero
xor esi,esi
mov edi,100000h
mov al,[esi]
mov ah,al
not al
xchg al,[edi]
cmp ah,[esi]
mov [edi],al
pop edi esi ds
ret
Regards,
Alex
.