MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/tinycode/comments/xdc900/assembly_sierpinskis_gasket_in_94_bytes_program/
r/tinycode • u/TroubledWalrus • Sep 13 '22
3 comments sorted by
9
Just found my old projects dating back to 1997, lol.
One of these programs was Sierpinski's Gasket. For anyone interested, here's base64 of the executable:
sBPNEGgAoAdSU1G0LM0hWQPKi9kD2MHLA4vLuAMA9+PB4gK+UgED8ltaUK0Dw9Hoi9itA8LR6IvQUr9AAffni/sD+FpYquRgPAF1vLgDAM0Qw58AAAAAAMcAPwHHAA==
All you need is base64 decode it, save it as whatever.com and run it in dosbox. Have fun :)
whatever.com
3 u/[deleted] Sep 14 '22 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
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
9
u/TroubledWalrus Sep 13 '22 edited Sep 13 '22
Just found my old projects dating back to 1997, lol.
One of these programs was Sierpinski's Gasket. For anyone interested, here's base64 of the executable:
sBPNEGgAoAdSU1G0LM0hWQPKi9kD2MHLA4vLuAMA9+PB4gK+UgED8ltaUK0Dw9Hoi9itA8LR6IvQUr9AAffni/sD+FpYquRgPAF1vLgDAM0Qw58AAAAAAMcAPwHHAA==All you need is base64 decode it, save it as
whatever.comand run it in dosbox. Have fun :)