From vixen.cso.uiuc.edu!newsfeed.internetmci.com!news.albany.net!news.sover.net!

news.sprintlink.net!news-pen-4.sprintlink.net!news.sprintlink.net!news-dc-10.spr

intlink.net!news.msn.com!msn.com Mon Jul 15 17:44:06 1996

From: davids@msn.com (David Stafford)

Subject: Re: Justin's Contest - now 29 bytes

Date: 15 Jul 96 21:14:48 -0700

References: <4s1o71$dj1@news2.texas.net> <4se340$oj4@news2.texas.net>

Message-ID: <00001a76+00002765@msn.com>

Path: vixen.cso.uiuc.edu!newsfeed.internetmci.com!news.albany.net!news.sover.net

!news.sprintlink.net!news-pen-4.sprintlink.net!news.sprintlink.net!news-dc-10.sp

rintlink.net!news.msn.com!msn.com

Newsgroups: comp.lang.asm.x86

Organization: The Microsoft Network (msn.com)

Lines: 45

I found a way to keep the color visible and squeezed a couple more

bytes out of my code.

; Draws a Serpinski triangle

; David Stafford

; 7/15/96

; 8086 code, assemble to a COM file

; 29 bytes

code segment

assume cs:code,ds:code,es:code,ss:code

org 100h ;for COM files

Start:

mov al,13h ;assume ah = 0 (true for COM files)

int 10h ;set VGA 320x200 256-color mode

mov bl,3 ;bx = 3, assume bh = 0

;comes in handy in two places below

mov si,0A1E0h - 320 ;ds = video memory, si = offset

mov ds,si ;small and very cute, the segment

;offset and counter are identical

db 0b9h ;MOV CX,0C8Bh where 0C = color red

;skip the next instr the first time

;I can make this use white but it

;costs one more byte

DrawLoop:

mov cx,[si] ;order is important! 8B 0C

xor ch,[bx+si] ;handy place #1 (bx = 3)

mov [si-318],ch

dec si ;dec pointer

jnz DrawLoop

int 16h ;assume ah = 0, wait for keystroke

xchg ax,bx ;handy place #2 (bx = 3)

int 10h ;set 80x25 text mode

ret ;exit (returns to cs:0000 where

;there is an INT 20h for COM files)

ends