MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/tinycode/comments/xdc900/assembly_sierpinskis_gasket_in_94_bytes_program/iodcc01/?context=3
r/tinycode • u/TroubledWalrus • Sep 13 '22
3 comments sorted by
View all comments
Show parent comment
3
Nice! Do you still have the original source code?
6 u/TroubledWalrus Sep 14 '22 .286code segmentorg 100hassume cs:code,ds:code; ------------start:mov al,13hint 10h ; 320x200x256push 0a000h ; video segment -> stackpop es ; ES <- video segmentmain:push dx ; point Y -> stackpush bx ; point X -> stackpush cx ; randseed -> stackmov ah,2ch ; get current timeint 21h ; (slows down program like hell!)pop cx ; randseed <- stackadd cx,dx ; randseed = randseed + 1/100 secmov bx,cxadd bx,axror bx,3 ; generate "random" number (0, 1 or 2)mov cx,bx ; and put it to dxmov ax,3mul bxshl dx,2lea si,points ; choose vertexadd si,dxpop bx ; point X <- stackpop dx ; point Y <- stackpush ax ; color -> stack (will be "random", too)lodsw ; get vertex X coordinateadd ax,bx ; estimate halfwayshr ax,1 ; between vertex and point Xmov bx,ax ; point X <- new point Xlodsw ; get vertex Y coordinateadd ax,dx ; estimate halfwayshr ax,1 ; between vertex and point Ymov dx,ax ; point Y <- new point Ypush dx ; point Y -> stackmov di,320mul di ; multiply point Y by 320mov di,bx ; move point X to DIadd di,ax ; add point Y to DIpop dx ; point Y <- stackpop ax ; color <- stackstosb ; display itin al,60hcmp al,1 ; esc pressed?jne mainmov ax,3 ; restore text modeint 10hret ; finish it; ------------points dw 159,0dw 0,199 ; vertex coordinatesdw 319,199code endsend start
6
.286
code segment
org 100h
assume cs:code,ds:code
; ------------
start:
mov al,13h
int 10h ; 320x200x256
push 0a000h ; video segment -> stack
pop es ; ES <- video segment
main:
push dx ; point Y -> stack
push bx ; point X -> stack
push cx ; randseed -> stack
mov ah,2ch ; get current time
int 21h ; (slows down program like hell!)
pop cx ; randseed <- stack
add cx,dx ; randseed = randseed + 1/100 sec
mov bx,cx
add bx,ax
ror bx,3 ; generate "random" number (0, 1 or 2)
mov cx,bx ; and put it to dx
mov ax,3
mul bx
shl dx,2
lea si,points ; choose vertex
add si,dx
pop bx ; point X <- stack
pop dx ; point Y <- stack
push ax ; color -> stack (will be "random", too)
lodsw ; get vertex X coordinate
add ax,bx ; estimate halfway
shr ax,1 ; between vertex and point X
mov bx,ax ; point X <- new point X
lodsw ; get vertex Y coordinate
add ax,dx ; estimate halfway
shr ax,1 ; between vertex and point Y
mov dx,ax ; point Y <- new point Y
mov di,320
mul di ; multiply point Y by 320
mov di,bx ; move point X to DI
add di,ax ; add point Y to DI
pop ax ; color <- stack
stosb ; display it
in al,60h
cmp al,1 ; esc pressed?
jne main
mov ax,3 ; restore text mode
int 10h
ret ; finish it
points dw 159,0
dw 0,199 ; vertex coordinates
dw 319,199
code ends
end start
View all comments
Show parent comment
3
u/[deleted] Sep 14 '22
Nice! Do you still have the original source code?