Annotation of OpenXM_contrib/gnuplot/lineproc.mac, Revision 1.1.1.1
1.1 maekawa 1: ; lineproc.mac
2: ; MASM macro definition for Bresenham line-drawing routine
3: ; Colin Kelley
4: ; January 13, 1987
5:
6:
7: INCAX equ 40h ; for Self-Modifying Code
8: INCBX equ 43h
9: DECAX equ 48h
10: DECBX equ 4bh
11:
12: ; usage:
13: ; lineproc linename, pixelname
14: ;
15: ; where linemane is the name you want for the proc, and pixelname is the
16: ; name of the routine that linename is to call to set pixels
17: ;
18:
19: lineproc macro linename, pixelname
20: beginproc linename
21:
22: push bp
23: mov bp,sp
24: push si
25: push di
26: mov ax,[bp+X] ; x1
27: mov bx,[bp+X+2] ; y1
28: mov cx,[bp+X+4] ; x2
29: mov si,[bp+X+6] ; y2
30:
31: cmp ax,cx ; x1,x2
32: jne i19
33: cmp bx,si ; y1,y2
34: jne i19
35:
36: call pixelname
37:
38: jmp i28
39: i19:
40: mov dx,ax ; dx,x1
41: sub dx,cx ; x2
42: jnc noabsx
43: neg dx
44: noabsx:
45: mov di,bx ; dy,y1
46: sub di,si ; y2
47: jnc noabsy
48: neg di ; dy
49: noabsy:
50: cmp dx,di ; dx,dy
51: jb i21 ; go iterate y's
52: ;
53: ; iterate x's
54: ;
55: cmp bx,si ; y1,y2
56: jb forwardy
57: mov byte ptr cs:yinc1,DECBX
58: jmp short i22
59: forwardy:
60: mov byte ptr cs:yinc1,INCBX
61: i22:
62: cmp ax,cx ; x1,x2
63: jae l20004
64: mov byte ptr cs:xinc1,INCAX
65: jmp short l20005
66: l20004:
67: mov byte ptr cs:xinc1,DECAX
68: l20005:
69: mov bp,dx ; sum,dx
70: shr bp,1 ; sum
71: d23:
72: cmp ax,cx ; x1,x2
73: je i28 ; done
74: xinc1: inc ax ; may become inc or dec
75: add bp,di ; sum,dy
76: cmp bp,dx
77: jb i27
78: sub bp,dx ; sum,dx
79: yinc1: inc bx ; may become inc or dec
80: i27:
81: call pixelname
82: jmp short d23
83:
84: ;
85: ; else iterate y's
86: ;
87: i21:
88: cmp ax,cx ; x1,x2
89: jae l20006
90: mov byte ptr cs:xinc2,INCAX
91: jmp short l20007
92: l20006:
93: mov byte ptr cs:xinc2,DECAX
94: l20007:
95: cmp bx,si ; y1,y2
96: jb forwardy2
97: mov byte ptr cs:yinc2,DECBX
98: jmp short i29
99: forwardy2:
100: mov byte ptr cs:yinc2,INCBX
101: i29:
102: mov bp,di ; sum,dy
103: shr bp,1 ; sum,1
104: d30:
105: cmp bx,si ; y1,y2
106: je i28
107: yinc2: inc bx ; may become inc or dec
108: add bp,dx ; sum,dx
109: cmp bp,di ; sum,dy
110: jb i34
111: sub bp,di ; sum,dy
112: xinc2: inc ax ; may become inc or dec
113: i34:
114: call near ptr pixelname
115: jmp short d30
116: ;
117: ; clean up and exit
118: ;
119: i28:
120: pop di
121: pop si
122: pop bp
123: ret
124:
125: linename endp
126: endm
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>