Original Post
i''m having some trouble with an assembly implementation of the midpoint line algorithm. i think the problem occurs with the sign testing, but i''m not really sure. thanks in advance.
line PROC near
LOCAL a :WORD
LOCAL b :WORD
LOCAL G :WORD
LOCAL D1 :WORD
LOCAL D2 :WORD
push bp
mov bp, sp
pusha
mov ax, 199 ;y2
sub ax, 0 ;y1
mov a, ax
mov ax, 319 ;x2
sub ax, 0 ;x1
mov b, ax
mov ax, a
shl ax, 1
mov D2, ax
sub ax, b
mov G, ax
mov ax, a
sub ax, b
shl ax, 1
mov D1, ax
mov bx, 0 ;y1
mov si, bx
xchg bh, bl
shl si, 6
add si, bx
add si, 0 ;x1
mov di, 0 ;x1
push 0A000h
pop es
mov ax, D1
mov bx, D2
mov cx, G
mov dl, 0Fh ;linecol
mov es:[si], dl
plot1:
or cx, cx ;test if signed
jle plot2 ;this is the problem i think
add cx, ax
add si, 321
jmp plot3
plot2:
add cx, bx
inc si
plot3:
mov es:[si], dl
inc di
cmp di, 319 ;x2
jb plot1
exitp:
popa
pop bp
ret 9
ENDP