include irvine16.inc .686 .data six word 6 five word 5 left word ? top word ? ddx dword ? dy dword ? height dword 480 xwidth dword 640 i word ? minus1 word -1 psize word ? dummy dword ? colorct word ? j word ? ;double xmin = -2.5; // The ranges of x and y coordinates that ; double xmax = 1; // are represented by this drawing surface ; double ymin = -1.25; ; double ymax = 1.25; xmin dword -5 xmax dword 1 ymin dword -5 ymax dword 5 two word 2 four word 4 hundred word 100 zx dword ? zy dword ? x dword ? y dword ? .code main proc near mov ax,@data mov ds,ax mov es,ax ;;init double precision data values fild xmin fidiv two fstp xmin fild ymin fidiv four fstp ymin fild ymax fidiv four fistp ymax fild xmax fstp xmax mov ah,0fh int 10h push ax call b10mode ; call c10display call mand mov ah,10h int 16h pop ax mov ah,0 int 10h mov ax,4c00h int 21h main endp b10mode proc near mov ax,12h int 10h mov ah,0bh mov bx,7 int 10h ret b10mode endp mand proc ; int i,j; ; int size; // The size of the square that needs to be drawn. ; ; int colorIndex; ; ; public void paint(Graphics g) { ; //draws the Mandelbrot set ; int width = 640; // Current size of this canvas. ; int height = 400; ; ; g.setColor(Color.black); ; g.fillRect(0,0,width,height); ; ; size=2 mov psize,2 ; // Outer for loop performs one pass, filling ; // the image with squares of the given size. ; // The size here is given in terms of pixels. ; float dx,dy; // Size of square in real coordinates. ; dx = (xmax - xmin)/width * size; ; dy = (ymax - ymin)/height * size; fld xmax fsub xmin fidiv xwidth fimul psize fstp ddx fld ymax fsub ymin fidiv height fimul psize fstp dy ; float x = xmin + dx/2; // x-coord of center of square. fld ddx fidiv two fimul minus1 fadd xmin fstp x ; for (i = size/2; i < width+size/2 ; i += size) { mov i,1 outer: cmp i, 640 jge doneouter ; float y = ymax - dy/2; // y-coord of center of square fld dy fidiv two fimul minus1 fadd ymax fstp y ; // First nested for loop draws one column of squares. ; for (j = size/2; j < height+size/2 ; j += size) { ; mov j,1 inner: cmp j,480 jge doneinner ; colorIndex = countIterations(x,y); call countiterations ; ;int left = i - size/2; mov ax,i ;sub ax,psize mov left,ax ; int top = j - size/2; mov ax,j ;sub ax, psize mov top, ax ; g.setColor( Color.getHSBColor(colorIndex/100.0F,1F,1F) ); mov ax,cx xor dx,dx div six ; g.fillRect(left,top,size,size); call putdot; left,top,psize,psize ; y -= dy; fld y fsub dy fstp y inc j jmp inner ; } doneinner: ; x += ddx; fld x fadd ddx fstp x inc i jmp outer ; doneouter: ; } ; ; } // end paint() ret mand endp putdot proc pusha mov ah,0ch mov bh,0 ;;;al is color mov cx,left mov dx,top int 10h popa ret putdot endp countIterations proc ; int count = 0; ; double zx = x; ; double zy = y; ; while (count < 80 && Math.abs(zx) < 100 && Math.abs(zy) < 100) { ; double new_zx = zx*zx - zy*zy + x; ; zy = 2*zx*zy + y; ; zx = new_zx; ; count++; ; } ; return count; ; } mov eax,x mov zx,eax mov eax,y mov zy,eax mov cx,0 ctop: cmp cx,80 jge donecountcx fild hundred fld zx fabs fcomi st(0),st(1) jnb donecountzx fld zy fabs fcomi st(0),st(2) jnb donecountzy fstp dummy fstp dummy fstp dummy fld zy fmul zy;zy*zy fld zx fmul zx;zx*zx fsub st(0),st(1) fadd x fxch fdiv zy fmul zx fimul two fadd y fstp zy fstp zx inc cx jmp ctop donecountzy:fstp dummy donecountzx:fstp dummy fstp dummy donecountcx: ret ;;;cx is ans countiterations endp ; int countIterations(double x, double y) { to be called XARG, YARG ; // The Mandelbrot set is represented by coloring ; // each point (x,y) according to the number of ; // iterations it takes before the while loop in ; // this method ends. For points that are actually ; // in the Mandelbrot set, or very close to it, the ; // count will reach the maximum value, 80. These ; // points will be colored purple. All other colors ; // represent points that are definitely NOT in the set. end main