主题:请教各位高手,帮我看看这个汇编程序 急急急
我是在编一个画圆的程序
[color=00FF00]
1.首先我写一个程序,把圆分成4部分,逐一画,最后画的圆很不圆,周边成锯齿状,我知道这与显示像素大小有关,想有一个好的解决方法!不仅如此,而且在屏幕上显示的不只是一个圆,还有其成块的杂白色!不知什么原因!请教解决我的程序如下,同时我把asm文件也上传了,在附件里,您看看![/color]
square macro opr
mov ax,opr
mul ax
endm
data segment
x0 dw 150
y0 dw 100
r dw 30
data ends
code segment
assume cs:code ,ds:data
main proc far
start:
mov ax,data
mov ds,ax
mov ah,00
mov al,04h
int 10h
mov ah,0bh
mov bh,00
mov bl,1
int 10h
mov ah,0bh
mov bh,01
mov bl,01
int 10h
mov si,x0
mov di,y0
nextcol:
push si
sub si,x0
square si
mov cx,ax
square r
sub ax,cx
mov cx,ax
pop si
col:
push bx
mov bx,y0
sub bx,di
square bx
pop bx
cmp ax,cx
ja fornext
push cx
mov al,3
mov ah,0ch
mov cx,si
mov dx,di
int 10h
pop cx
dec di
jmp col
fornext:
inc si
mov cx,x0
add cx,r
cmp si,cx
ja exit1
mov di,y0
jmp nextcol
exit1:
mov si,x0
mov di,y0
nextcol1:
push si
sub si,x0
square si
mov cx,ax
square r
sub ax,cx
mov cx,ax
pop si
col1:
push bx
mov bx,y0
sub bx,di
square bx
pop bx
cmp ax,cx
ja fornext1
push cx
mov al,3
mov ah,0ch
mov cx,si
mov dx,di
int 10h
pop cx
inc di
jmp col1
fornext1:
inc si
mov cx,x0
add cx,r
cmp si,cx
ja exit2
mov di,y0
jmp nextcol1
exit2:
mov si,x0
mov di,y0
nextcol2:
push si
sub si,x0
square si
mov cx,ax
square r
sub ax,cx
mov cx,ax
pop si
col2:
push bx
mov bx,y0
sub bx,di
square bx
pop bx
cmp ax,cx
ja fornext2
push cx
mov al,3
mov ah,0ch
mov cx,si
mov dx,di
int 10h
pop cx
dec di
jmp col2
fornext2:
dec si
mov cx,x0
sub cx,r
cmp si,cx
jb exit3
mov di,y0
jmp nextcol2
exit3:
mov si,x0
mov di,y0
nextcol3:
push si
sub si,x0
square si
mov cx,ax
square r
sub ax,cx
mov cx,ax
pop si
col3:
push bx
mov bx,y0
sub bx,di
square bx
pop bx
cmp ax,cx
ja fornext3
push cx
mov al,3
mov ah,0ch
mov cx,si ;列
mov dx,di ;行
int 10h
pop cx
inc di
jmp col3
fornext3:
dec si
mov cx,x0
add cx,r
cmp si,cx
ja exit
mov di,y0
jmp nextcol3
exit :
mov dx,65000
call delay
mov ah,00
mov al,3
int 10h
mov ax,4c00h
int 21h
main endp
delay proc near
wait1:
mov cx,40000
wait2:
loop wait2
dec dx
jnz wait1
ret
delay endp
code ends
end start
[color=FF00FF][size=3]2.为了能使圆能更圆一些,我用另一种方法画圆,可是这个程序,能运行,却在屏幕上什么页显示不了!不知什么原因!请教解决![/size][/color]
data segment
N0=10000 ;比例因子
N1 dw 150
N2 dw 200 ;圆心坐标
D1 dw 0
D2 dw 80 ;圆半径
D3 dw 0,349,698,1045,1392,1736,2079,2419
dw 2756,3090,3420,3746,4067,4384,4695
dw 5000,5299,5592,5878,6157,6428,6691
dw 6947,7193,7431,7660,7880,8090,8290
dw 8480,8660,8829,8988,9135,9272,9397
dw 9511,9613,9703,9781,9848,9903,9945
dw 9976,9994,10000 ;余弦函数表
N=$-D3 ;对称,实现相应正弦函数
data ends
stack segment stack
dw 100 dup(?)
tos label word
stack ends
code segment
assume cs:code,ds:data,ss:stack
main proc far
push ds
mov ax,0
push ax
mov ax,data
mov ds,ax
mov ah,00
mov al,04h
int 10h ;图形4色
mov ah,0bh
mov bh,00
mov bl,1
int 10h ;设置背景色
mov ah,0bh
mov bh,01 ;浅蓝
mov bl,01
int 10h ;设置彩色组
call draw
mov ah,0
mov al,3
int 10h
mov ax,4c00h
int 21h
main endp
draw proc near
lea si,D3 ;si为首地址
mov di,si
add di,N-2;di为末地址
mov cx,N0 ;比例
mov bx,D2 ;半径
q1:
call dxdy ;画圆的第一区
neg ax
add ax,N1 ; y0-Δy
neg dx
add dx,N2 ; x0-Δx
call point
add D1,2
cmp D1,90
jb q1
q2:
call dxdy
add ax,N1
neg dx
add dx,N2
call point
sub D1,2
cmp D1,0
jge q2
mov dl,0
q3:
call dxdy
add ax,N1
add dx,N2
call point
add D1,2
cmp D1,90
jb q3
q4:
call dxdy
neg dx
add ax,N1
add dx,N2
call point
sub D1,2
cmp D1,0
jge q4
ret
draw endp
point proc ;写入像素
push cx
mov cx,ax
mov ah,12
mov al,3
int 10h
call delay
pop cx
ret
point endp
dxdy proc
push si
push D1
add si,D1
mov ax,[si] ;计算Δx=(R*cosi)/比例因子N0
mul bx
div cx
push ax
sub di,D1
mov ax,[di]
mul bx
div cx
mov dx,10 ;计算Δy=(R*sini)/比例因子N0
mul dx
mov dl,10
div dl
mov ah,0
pop dx ;结果Δx存在dx;Δy存在ax
pop di
pop si
ret
dxdy endp
delay proc near
wait1:
mov cx,40000
wait2:
loop wait2
dec dx
jnz wait1
ret
delay endp
code ends
end main
[color=00FF00]
1.首先我写一个程序,把圆分成4部分,逐一画,最后画的圆很不圆,周边成锯齿状,我知道这与显示像素大小有关,想有一个好的解决方法!不仅如此,而且在屏幕上显示的不只是一个圆,还有其成块的杂白色!不知什么原因!请教解决我的程序如下,同时我把asm文件也上传了,在附件里,您看看![/color]
square macro opr
mov ax,opr
mul ax
endm
data segment
x0 dw 150
y0 dw 100
r dw 30
data ends
code segment
assume cs:code ,ds:data
main proc far
start:
mov ax,data
mov ds,ax
mov ah,00
mov al,04h
int 10h
mov ah,0bh
mov bh,00
mov bl,1
int 10h
mov ah,0bh
mov bh,01
mov bl,01
int 10h
mov si,x0
mov di,y0
nextcol:
push si
sub si,x0
square si
mov cx,ax
square r
sub ax,cx
mov cx,ax
pop si
col:
push bx
mov bx,y0
sub bx,di
square bx
pop bx
cmp ax,cx
ja fornext
push cx
mov al,3
mov ah,0ch
mov cx,si
mov dx,di
int 10h
pop cx
dec di
jmp col
fornext:
inc si
mov cx,x0
add cx,r
cmp si,cx
ja exit1
mov di,y0
jmp nextcol
exit1:
mov si,x0
mov di,y0
nextcol1:
push si
sub si,x0
square si
mov cx,ax
square r
sub ax,cx
mov cx,ax
pop si
col1:
push bx
mov bx,y0
sub bx,di
square bx
pop bx
cmp ax,cx
ja fornext1
push cx
mov al,3
mov ah,0ch
mov cx,si
mov dx,di
int 10h
pop cx
inc di
jmp col1
fornext1:
inc si
mov cx,x0
add cx,r
cmp si,cx
ja exit2
mov di,y0
jmp nextcol1
exit2:
mov si,x0
mov di,y0
nextcol2:
push si
sub si,x0
square si
mov cx,ax
square r
sub ax,cx
mov cx,ax
pop si
col2:
push bx
mov bx,y0
sub bx,di
square bx
pop bx
cmp ax,cx
ja fornext2
push cx
mov al,3
mov ah,0ch
mov cx,si
mov dx,di
int 10h
pop cx
dec di
jmp col2
fornext2:
dec si
mov cx,x0
sub cx,r
cmp si,cx
jb exit3
mov di,y0
jmp nextcol2
exit3:
mov si,x0
mov di,y0
nextcol3:
push si
sub si,x0
square si
mov cx,ax
square r
sub ax,cx
mov cx,ax
pop si
col3:
push bx
mov bx,y0
sub bx,di
square bx
pop bx
cmp ax,cx
ja fornext3
push cx
mov al,3
mov ah,0ch
mov cx,si ;列
mov dx,di ;行
int 10h
pop cx
inc di
jmp col3
fornext3:
dec si
mov cx,x0
add cx,r
cmp si,cx
ja exit
mov di,y0
jmp nextcol3
exit :
mov dx,65000
call delay
mov ah,00
mov al,3
int 10h
mov ax,4c00h
int 21h
main endp
delay proc near
wait1:
mov cx,40000
wait2:
loop wait2
dec dx
jnz wait1
ret
delay endp
code ends
end start
[color=FF00FF][size=3]2.为了能使圆能更圆一些,我用另一种方法画圆,可是这个程序,能运行,却在屏幕上什么页显示不了!不知什么原因!请教解决![/size][/color]
data segment
N0=10000 ;比例因子
N1 dw 150
N2 dw 200 ;圆心坐标
D1 dw 0
D2 dw 80 ;圆半径
D3 dw 0,349,698,1045,1392,1736,2079,2419
dw 2756,3090,3420,3746,4067,4384,4695
dw 5000,5299,5592,5878,6157,6428,6691
dw 6947,7193,7431,7660,7880,8090,8290
dw 8480,8660,8829,8988,9135,9272,9397
dw 9511,9613,9703,9781,9848,9903,9945
dw 9976,9994,10000 ;余弦函数表
N=$-D3 ;对称,实现相应正弦函数
data ends
stack segment stack
dw 100 dup(?)
tos label word
stack ends
code segment
assume cs:code,ds:data,ss:stack
main proc far
push ds
mov ax,0
push ax
mov ax,data
mov ds,ax
mov ah,00
mov al,04h
int 10h ;图形4色
mov ah,0bh
mov bh,00
mov bl,1
int 10h ;设置背景色
mov ah,0bh
mov bh,01 ;浅蓝
mov bl,01
int 10h ;设置彩色组
call draw
mov ah,0
mov al,3
int 10h
mov ax,4c00h
int 21h
main endp
draw proc near
lea si,D3 ;si为首地址
mov di,si
add di,N-2;di为末地址
mov cx,N0 ;比例
mov bx,D2 ;半径
q1:
call dxdy ;画圆的第一区
neg ax
add ax,N1 ; y0-Δy
neg dx
add dx,N2 ; x0-Δx
call point
add D1,2
cmp D1,90
jb q1
q2:
call dxdy
add ax,N1
neg dx
add dx,N2
call point
sub D1,2
cmp D1,0
jge q2
mov dl,0
q3:
call dxdy
add ax,N1
add dx,N2
call point
add D1,2
cmp D1,90
jb q3
q4:
call dxdy
neg dx
add ax,N1
add dx,N2
call point
sub D1,2
cmp D1,0
jge q4
ret
draw endp
point proc ;写入像素
push cx
mov cx,ax
mov ah,12
mov al,3
int 10h
call delay
pop cx
ret
point endp
dxdy proc
push si
push D1
add si,D1
mov ax,[si] ;计算Δx=(R*cosi)/比例因子N0
mul bx
div cx
push ax
sub di,D1
mov ax,[di]
mul bx
div cx
mov dx,10 ;计算Δy=(R*sini)/比例因子N0
mul dx
mov dl,10
div dl
mov ah,0
pop dx ;结果Δx存在dx;Δy存在ax
pop di
pop si
ret
dxdy endp
delay proc near
wait1:
mov cx,40000
wait2:
loop wait2
dec dx
jnz wait1
ret
delay endp
code ends
end main