Created
April 15, 2020 19:14
-
-
Save loveJesus/29b85c3d8d6f4fa5cc85d4f33cf446c0 to your computer and use it in GitHub Desktop.
Aleluya, a simple 44byte dos asm intro.
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
;Aleluya, a simple 44byte dos asm intro. Compile with "nasm aleluya.asm -o aleluya.com" . | |
BITS 16 ; 16bit asm code | |
org 100h ; 'boilerplate' assembly directive for offest of dos com programs | |
section .text ; starting the code section, memory variables and data are different | |
push 0xA000 ; This is the base location of video memory in mode 13h | |
pop es ; ES register cannot be set directly by an immediate (a direct number) | |
mov ax, 13h ; these two lines set a simple flat video mode called 13h | |
int 10h ; with 320x200 pixels and 256 color palette | |
mov dx,0 ; we will use DX as a frame counter | |
frame_loop_aleluya: ; our label for the start of drawing a frame, aleluya! | |
mov di, 320*200 ; DI will both be used to countdown to 0 and to point to the pixel in memory | |
pixel_loop_aleluya: ; label for start of a pixel | |
mov bx, di ; we will operate on the counter within BX | |
add bx, dx ; move the bars every frame | |
and bl, 0xf ; modulus 16 of BL, the lowest 8 bits of BX (we write a byte=pixel at a time) | |
add bl, 16 ; add 16 so it is in a grayscale range of the default 256 color palette | |
mov [es:di], bl ; place from byte register al to [0xA000:di] | |
dec di ; countdown to 0 to finish frame | |
jnz pixel_loop_aleluya ; if last operation did not set 0 flag, the write next pixel | |
inc dx ; increment frame counter | |
mov ah, 1 ; these two lines detect the keypress | |
int 16h ; if a key is *not* pressed, the zero flag will be set | |
jz frame_loop_aleluya ; render another frame if zero flag not set | |
mov ax, 3h ; these two lines go back to standard dos text mode | |
int 10h | |
ret ; end program, but your life doesn't need to end, For God so loved the world, | |
; That He gave His only begotten Son, that all who believe in him should not perish but have everlasting life |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment