1 ; Some routines for managing the A20 line
3 ; Check if A20 is enabled
4 ; Based on <https://wiki.osdev.org/A20_Line#Testing_the_A20_line>, slightly modified
7 ; save segment and index registers
13 cli ; disable interrupts
18 mov ds, ax ; ds = FFFFh
23 mov al, [es:di] ; preserve contents of 0:500h
24 mov ah, [ds:si] ; preserve contents of FFFFh:510h
25 push ax ; push all that to stack
27 mov byte [es:di], 0 ; set 0:500h to 0
28 mov byte [ds:si], 0FFh ; set FFFFh:510h to FFh
30 cmp byte [es:di], 0FFh ; compare 0:500h with FFh
31 ; if A20 is enabled, this will not be equal, but if A20 is disabled it will be
33 pop ax ; pop old contents of the 2 addresses
34 mov [ds:si], ah ; restore contents of FFFFh:510h
35 mov [es:di], al ; restore contents of 0:500h
38 je .exit ; if A20 is disabled, return 0
39 mov ax, 1 ; otherwise return 1