Motorola DSP96002 User Manual page 598

32-bit digital signal processor
Table of Contents

Advertisement

B.1.43.2 Integer Incremental Line Drawing Algorithm
This implementation of line drawing uses Bresenham's algorithm. This algorithm uses only integer opera-
tions to generate the points.
;
Bresenham Line Drawing Implementation
;
;
When entering subroutine, the registers must
;
be set as follows:
;
;
d0 =
;
d1 =
;
d2 = x1
;
d3 = y1
;
;
When entering a line drawing loop, the registers
;
are set as follows:
;
;
d6 = x0
;
d7 = y0
;
d4 = dmajor
;
d5 = n0 = dminor
;
r0 = dmajor/2
;
m0 = dmajor - 1
org
; Calculate dx and dy
_line
sub
sub
; Determine whether to increment x or y
tst
neg
tst
neg
cmp
jge
; Increment y case
; If dy is negative, switch endpoints and sign of dx and dy
_inc_y
tst
tfr
tfr
MOTOROLA
d4 =
d5 =
d6 = x0
d7 = y0
p:$50
d6,d2
d2.l,d4.l
d7,d3
d3.l,d5.l
d2
d2.l,d0.l
d2
iflt
d3
d3.l,d1.l
d3
iflt
d3,d2
_inc_x
d1
d4,d6
iflt
d5,d7
iflt
DSP96002 USER'S MANUAL
B-79

Advertisement

Table of Contents
loading

Table of Contents