Skip to content

Instantly share code, notes, and snippets.

@q6r
Created August 10, 2014 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save q6r/d544cc2e47fc489e6c9e to your computer and use it in GitHub Desktop.
Save q6r/d544cc2e47fc489e6c9e to your computer and use it in GitHub Desktop.
bits 16
section .text
global _start
_start:
mov ax, 0x13
int 0x10
push 0xa000
pop ds
xor dx, dx
xor bp, bp
mov al, black
mov bx, vga
call bg
mov ax, 40*1
call hline
mov ax, 40*2
call hline
mov ax, 40*3
call hline
mov ax, 40*4
call hline
mov ax, 30
call vline
mov ax, 30*3+10
call vline
mov ax, 30*6+10
call vline
xor ax, ax
not ax
sub ax, 60
call vline
mov word [cloc], 0x0f0f*4+80
call circle
mov word [cloc], 0x0f0f*7+100
call circle
mov word [cloc], 0x0f0f*11+100+80+30
call circle
mov word [cloc], 0x0f0f*11+100+80+10+(320/3)
call circle
mov word [cloc], 0x0f0f*11+100+80+10+(320/3)*2-40
call circle
sleep: jmp sleep
circle:
xor dx, dx
xor bp, bp
mov ax, rad
mov bx, ax
mov si, 1
mov di, (((rad*rad)-rad)/2)-1
lea cx, [bx+si]
cia:
pusha
sub ax, rad
mov cl, 4
cib:
imul di, ax, 320
add di, word [cloc]
mov byte [di+bx], red
sub di, word [cloc]
xchg ax, bx
imul di, ax, 320
add di, word [cloc]
mov byte [di+bx], white
sub di, word [cloc]
neg ax
add ax, (rad*2)
loop cib
popa
add bp, si
inc si
lea dx, [bp+di-((rad*rad)/2)]
dec bx
cmp dx, ax
ja cia
sub di, cx
dec cx
inc ax
cmp si, cx
jna cia
xor ax, ax
mov ax, [cloc]
ret
bg:
dec bx
mov byte [bx], al
jnz bg
ret
vline:
mov es, word[vga]
mov di, 320*40
add di, ax
mov ax, white
mov cx, 120
vplot:
mov [di], al
add di, 320
loop vplot
ret
hline:
push ax
mov es, word [vga]
mov ax, 320
pop bx
mul bx
mov di, ax
mov cx, 320-90
mov ax, white
add di, 30
hplot:
mov byte [di], al
inc di
loop hplot
ret
pad: times 446 - ($-$$) db 0
ptable: times 64 db 0xff
sig: db 0x55, 0xaa
vga: equ 0xfa00
ioarr: equ 0x01
black: equ 0x00
red: equ 0x04
white: equ 0x0f
rad: equ 12
cloc: equ 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment