[BITS 16] enableA20: ; ------ Enable the A20 line. ; ------ [http://www.karig.net/2003-11/0003.html] ; ------ [based on "enableA20.s" by J. Andrew McLaughlin] ; Make sure interrupts are off! ; NOTE: Code sets up A20 line, but to write to memory > 1MB, ; you'll still need to set up either unreal mode or protected mode. mov cx, 5 mov dx, 0x64 jmp short .startAttempt1 .commandWait: in al, dx test al, 2 jnz .commandWait ret .getData: call .commandWait mov al, 0xD0 out dx, al .0: in al, dx test al, 1 jz .0 in al, 0x60 ret .startAttempt1: call .getData push ax call .commandWait mov al, 0xD1 out dx, al call .commandWait pop ax or al, 2 out 0x60, al call .getData and al, 2 jnz .exit loop .startAttempt1 mov cl, 5 .startAttempt2: call .commandWait mov al, 0xDF out dx, al call .getData and al, 2 jnz .exit loop .startAttempt2 .exit: test al, al sti jz .error ; Success -- do something here .error: ; Handle failure here