Skip to content

Instantly share code, notes, and snippets.

@jeandrek
Last active August 22, 2023 23:35
Show Gist options
  • Save jeandrek/965da4a45efd2193153d434ffdb375be to your computer and use it in GitHub Desktop.
Save jeandrek/965da4a45efd2193153d434ffdb375be to your computer and use it in GitHub Desktop.
.text
.globl _main
_main:
call ___djgpp_nearptr_enable
testl %eax, %eax
jz err
movw $0x13, %ax
int $0x10
movl $0xa0000, %ebx
subl ___djgpp_base_address, %ebx
# Fill background
pushl $(320 * 200)
pushl $17
pushl %ebx
call _memset
addl $12, %esp
# Draw circles
movl $75, %ecx
l2: pushl %ecx
call _circle
popl %ecx
subl $5, %ecx
testl %ecx, %ecx
jnz l2
call _getch
movw $0x3, %ax
int $0x10
call ___djgpp_nearptr_disable
xorl %eax, %eax
ret
err: movl $1, %eax
ret
.globl _circle
_circle:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
# Square radius
movl 8(%ebp), %eax
imull %eax
# Start at bottom (WRONG!!!)
movl 8(%ebp), %ecx
negl %ecx
l:
# Square y and take difference
movl %ecx, %edx
imull %edx, %edx
negl %edx
addl %eax, %edx
movl %edx, -4(%ebp)
# Find square root
fildl -4(%ebp)
fsqrt
fistpl -4(%ebp)
# Get screen coordinates
movl $100, %edx
subl %ecx, %edx
imull $320, %edx
addl %ebx, %edx
movl %edx, -8(%ebp)
addl -4(%ebp), %edx
addl $160, %edx
movb $6, (%edx)
movl $160, %edx
subl -4(%ebp), %edx
addl -8(%ebp), %edx
movb $6, (%edx)
cmpl %ecx, 8(%ebp)
pushf # So sorry
incl %ecx
popf
jne l
leave
ret
.data
n256: .long 256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment