Created
September 29, 2019 19:03
-
-
Save hikiko/ed23864f8c0c84d7d90cad3dd7c06623 to your computer and use it in GitHub Desktop.
DOS/asm: Showing the default palette
This file contains 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 | |
; DOS loads COM programs at offset 100h (256) of the program segment | |
; therefore we need to let the assembler know, that everything should | |
; start from address 100h | |
org 100h | |
; video bios (10h) call 00h: set video mode | |
; ah: 00h, al: video mode number | |
mov ax, 13h ; mode 13h (320x200 8bpp) | |
int 10h | |
; video memory 64000 bytes at a0000h (linear address) | |
; in seg:off notation, we can use seg: a000, offs 0 - 64000 | |
mov ax, 0a000h | |
mov es, ax ; we'll use es, to allow us to call rep stosd/movsd later | |
xor di, di ; initialize offset to 0 | |
xor cx, cx ; init y to 0 | |
yloop: xor bx, bx ; init x to 0 | |
xloop: mov ax, bx | |
cmp ax, 256 | |
jb skipclear | |
xor ax, ax | |
skipclear: | |
mov [es:di], al | |
inc di | |
inc bx | |
cmp bx, 320 | |
jnz xloop ; as long as ax is < 320, jump to xloop | |
inc cx | |
cmp cx, 200 | |
jnz yloop ; as long as cx is < 200, jump to yloop | |
; read the keyboard controller, and wait for ESC | |
kbwait: | |
in al, 60h ; read scancode (if available) | |
dec al ; esc == 1, so dec sets zero flag if escape is pressed | |
jnz kbwait ; if zero flag is not set, jump back to kbwait | |
; change back to text mode (mode 3) | |
mov ax, 3 | |
int 10h | |
; DOS terminate syscall | |
mov ax, 4c00h | |
int 21h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment