DATA segment
produ1 dw 4 dup(0)
produ2 dw 4 dup(0)
produ3 dw 4 dup(0)
produ4 dw 3000h dup(0)
produ5 dw 3000h dup(0)
r=181
x=300
y=240
DATA ends
code segment
assume cs:code,ds:DATA
start:
mov bx,505fh
mov ax,4f02h
int 10h
mov ax,DATA
mov ds,ax
mov si,0
mov cx,x-r
mov dx,y
mov al,02
mov ah,0ch
int 10h
lop1:mov dx,y
inc cx
mov produ1+2,cx
mov produ1+4,dx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov dx,produ1+4
mov cx,produ1+2
sub dx,bp
mov al,02
mov ah,0ch
int 10h
cmp cx,x
je exit1
cmp dx,y-r
je exit1
jmp lop1
exit1:
mov si,0
mov cx,x
mov dx,y-r
mov al,02
mov ah,0ch
int 10h
lop2:mov cx,x
inc dx
mov produ1+2,dx
mov produ1+4,cx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov cx,produ1+4
mov dx,produ1+2
sub cx,bp
cmp cx,x-r
je exit2
mov al,02
mov ah,0ch
int 10h
jmp lop2
exit2:
mov si,0
mov cx,x+r
mov dx,y
mov al,02
mov ah,0ch
int 10h
lop3:mov dx,y
dec cx
mov produ1+2,cx
mov produ1+4,dx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov dx,produ1+4
mov cx,produ1+2
sub dx,bp
cmp dx,y-r
je exit3
mov al,02
mov ah,0ch
int 10h
jmp lop3
exit3:
mov si,0
mov cx,x
mov dx,y-r
mov al,02
mov ah,0ch
int 10h
lop4:mov cx,x
inc dx
mov produ1+2,dx
mov produ1+4,cx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov cx,produ1+4
mov dx,produ1+2
add cx,bp
cmp cx,x+r
je exit4
mov al,02
mov ah,0ch
int 10h
jmp lop4
exit4:
mov si,0
mov cx,x
mov dx,y+r
mov al,02
mov ah,0ch
int 10h
lop5:mov cx,x
dec dx
mov produ1+2,dx
mov produ1+4,cx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov cx,produ1+4
mov dx,produ1+2
add cx,bp
cmp cx,x+r
je exit5
mov al,02
mov ah,0ch
int 10h
jmp lop5
exit5:
mov si,0
mov cx,x+r
mov dx,y
mov al,02
mov ah,0ch
int 10h
lop6:mov dx,y
dec cx
mov produ1+2,cx
mov produ1+4,dx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov dx,produ1+4
mov cx,produ1+2
add dx,bp
cmp dx,y+r
je exit6
mov al,02
mov ah,0ch
int 10h
jmp lop6
exit6:
mov si,0
mov cx,x-r
mov dx,y
mov al,02
mov ah,0ch
int 10h
lop7:mov dx,y
inc cx
mov produ1+2,cx
mov produ1+4,dx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov dx,produ1+4
mov cx,produ1+2
add dx,bp
cmp dx,y+r
je exit7
mov al,02
mov ah,0ch
int 10h
jmp lop7
exit7:
mov si,0
mov cx,x
mov dx,y+r
mov al,02
mov ah,0ch
int 10h
lop8:mov cx,x
dec dx
mov produ1+2,dx
mov produ1+4,cx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov cx,produ1+4
mov dx,produ1+2
sub cx,bp
cmp cx,x-r
je exit8
mov al,02
mov ah,0ch
int 10h
jmp lop8
exit8:
r=160
mov di,136
mov si,0
mov cx,x-r
mov dx,y
lop9:mov dx,y
inc cx
mov produ1+2,cx
mov produ1+4,dx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov dx,produ1+4
mov cx,produ1+2
sub dx,bp
cmp si,47
jb lop10
mov produ4[di],cx
mov produ5[di],dx
lop10:
add di,2
cmp cx,x
je exit9
cmp dx,y-r
je exit9
jmp lop9
exit9:
mov di,318
mov si,0
mov cx,x
mov dx,y-r
lop11:mov cx,x
inc dx
mov produ1+2,dx
mov produ1+4,cx
add si,1
mov ax,r
sub ax,si
mul ax
mov bx,ax
mov cx,dx
mov ax,r
mul ax
call shuangjian
call sqr
mov cx,produ1+4
mov dx,produ1+2
sub cx,bp
cmp si,47
jb lop12
mov produ4[di],cx
mov produ5[di],dx
lop12:
sub di,2
cmp cx,x-r
je exit10
jmp lop11
exit10:
mov di,0
lop1001:
mov si,0
mov cx,x
mov dx,y
mov al,02
mov ah,0ch
int 10h
mov produ3+1,0
lop1002:inc si
mov bx,x
sub bx,produ4[di]
mov ax,bx
mov bx,y
sub bx,produ5[di]
cmp ax,bx
jb exit1006
mul si
div bx
mov dx,240
sub dx,si
mov bp,ax
push bp
sub bp,produ3+1
lop1003:
dec bp
mov al,02
mov ah,0ch
int 10h
cmp bp,0
je exit1001
cmp dx,produ5[di]
jb exit1002
dec cx
jmp lop1003
exit1001:
pop bp
mov produ3+1,bp
cmp cx,produ4[di]
jb exit1002
loop lop1002
exit1002:
jmp exit1007
exit1006:jmp exit1005
exit1007:
call delay2
mov si,0
mov cx,x
mov dx,y
mov al,0
mov ah,0ch
int 10h
mov produ3+1,0
lop1004:inc si
mov bx,x
sub bx,produ4[di]
mov ax,bx
mov bx,y
sub bx,produ5[di]
cmp ax,bx
jb exit1005
mul si
div bx
mov dx,240
sub dx,si
mov bp,ax
push bp
sub bp,produ3+1
lop1005:
dec bp
mov al,0
mov ah,0ch
int 10h
cmp bp,0
je exit1003
cmp dx,produ5[di]
jb exit1004
dec cx
jmp lop1005
exit1003:
pop bp
mov produ3+1,bp
cmp cx,produ4[di]
jb exit1004
loop lop1004
exit1004:
add di,14
cmp di,1200
jg exit1005
jmp lop1001
exit1005:
lop2001:
mov si,0
mov cx,x
mov dx,y
mov al,02
mov ah,0ch
int 10h
mov produ3+1,0
lop2002:inc si
mov bx,y
sub bx,produ5[di]
mov ax,bx
mov bx,x
sub bx,produ4[di]
cmp bx,0
jb exit2002
mul si
div bx
mov dx,240
mov cx,x
sub cx,si
mov bp,ax
push bp
sub bp,produ3+1
sub dx,produ3+1
lop2003:
dec bp
mov al,02
mov ah,0ch
int 10h
cmp bp,0
je exit2001
cmp dx,produ5[di]
jb exit2002
dec dx
jmp lop2003
exit2001:
pop bp
mov produ3+1,bp
cmp cx,produ4[di]
jb exit2002
loop lop2002
exit2002:
call delay2
mov si,0
mov cx,x;=300
mov dx,y;240
mov al,01
mov ah,0ch
int 10h
mov produ3+1,0
lop2004:inc si
mov bx,y
sub bx,produ5[di]
mov ax,bx
mov bx,x
sub bx,produ4[di]
cmp bx,0
jb exit2005
mul si
div bx
mov dx,240
mov cx,x
sub cx,si
mov bp,ax
push bp
sub bp,produ3+1
sub dx,produ3+1
lop2005:
dec bp
mov al,01
mov ah,0ch
int 10h
cmp bp,0
je exit2003
cmp dx,produ5[di]
jb exit2005
dec dx
jmp lop2005
exit2003:
pop bp
mov produ3+1,bp
cmp cx,produ4[di]
jb exit2004
loop lop2004
exit2004:
add di,14
cmp di,550
jg exit2005
jmp lop2001
exit2005:
mov ah,1
int 21h
mov ah,4ch
int 21h
delay2 proc
mov ah,01
mov cx,0
mov dx,0
int 1ah
delay:mov ah,00
int 1ah
cmp dx,12h;●
jb delay
ret
delay2 endp
sqr proc
mov bp,0
mov dx,01
lop:sub bx,dx
jb end0
inc bp
add dx,02
jmp lop
end0:
ret
sqr endp
shuangjian proc
sub dx,cx
cmp ax,bx
jg reduce
xchg ax,bx
sub ax,bx
sub dx,0001
mov bx,9999
sub bx,ax
jmp ok
reduce:sub ax,bx
mov bx,ax
ok:add bx,1
ret
shuangjian endp
code ends
end start