Assembly Language for Beginners

(Jeff_L) #1
8.13. DEMOS

32 xor bx,bx
33 xor si,si
34
35 MandelLoop:
36 mov bp,si
37 imul si,bx
38 add si,si
39 imul bx,bx
40 jo MandelBreak
41 imul bp,bp
42 jo MandelBreak
43 add bx,bp
44 jo MandelBreak
45 sub bx,bp
46 sub bx,bp
47
48 sar bx,6
49 add bx,dx
50 sar si,6
51 add si,ax
52
53 loop MandelLoop
54
55 MandelBreak:
56 xchg ax,cx
57 stosb
58 cmp di, 0FA00h
59 jb FillLoop
60
61 ; wait for keypress
62 xor ax,ax
63 int 16h
64 ; set text video mode
65 mov ax, 3
66 int 10h
67 ; exit
68 int 20h


The author of these lines made an attempt to fix all these oddities: now the palette is smooth grayscale,
the video buffer is at the correct place (lines 19..20), the picture is drawn on center of the screen (line 30),
the program eventually ends and waits for the user’s keypress (lines 58..68).

But now it’s much bigger: 105 bytes (or 54 instructions)^54.

(^54) You can experiment by yourself: get DosBox and NASM and compile it as:nasm fiole.asm -fbin -o file.com

Free download pdf