Last active
January 30, 2024 01:51
-
-
Save sakamoto-poteko/0d50af2d9eb78f71c74f to your computer and use it in GitHub Desktop.
A20-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[bits 16] | |
org 07c00h | |
mov ax, cs | |
mov ds, ax | |
mov es, ax | |
call check_a20 | |
test ax, ax | |
mov ax, A20On | |
jnz Print ; Enabled | |
mov ax, A20Off | |
Print: | |
mov bp, ax | |
mov cx, 16 | |
mov ax, 01301h | |
mov bx, 000ch | |
mov dl, 0 | |
int 10h | |
cli ; Shutdown | |
hlt | |
check_a20: | |
push ds | |
push es | |
push di | |
push si | |
cli | |
xor ax, ax ; ax = 0 | |
mov es, ax | |
not ax ; ax = 0xFFFF | |
mov ds, ax | |
mov di, 0x0500 | |
mov si, 0x0510 | |
mov al, byte [es:di] | |
push ax | |
mov al, byte [ds:si] | |
push ax | |
mov byte [es:di], 0x00 | |
mov byte [ds:si], 0xFF | |
cmp byte [es:di], 0xFF | |
pop ax | |
mov byte [ds:si], al | |
pop ax | |
mov byte [es:di], al | |
mov ax, 0 | |
je check_a20__exit | |
mov ax, 1 | |
check_a20__exit: | |
pop si | |
pop di | |
pop es | |
pop ds | |
ret | |
A20On: | |
db "A20 is On " | |
A20Off: | |
db "A20 is Off " | |
times 510-($-$$) db 0 | |
db 0x55 | |
db 0xaa | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment