
 ; SINWGLI is a direct table look- up routine for SINe Wave. Generation using Linear Interpolation
 ; with any positive real delta greater than 0.0 and less than N/ 2.0. Here delta = 2.5 and is saved in y1 and y0.
 ; The sine table contains 256 (N) entries corresponding to the sines of 256 equally spaced angles
 ; between 0 and 360 degrees. N must be a power of two. The table size minus one, N- 1, is saved in N0.





start equ $60                    ;program starting address
sinep equ $100                   ;sine table starting address
mask equ $ff                     ;base address plus N minus one
delta equ 2.5                    ;delta = 2.5
sinea equ $ffe0                  ;address of output device
 org p: start

 movec #6, omr                   ;enable on- chip ROM with sine table
 move #sinea, r4                 ;set up output pointer

 move #( delta @cvi( delta)), bo ;store fraction part in b0

 asl b #sinep, r1                ;eliminate sign bit, initialize r1

 move #>@ cvi( delta), y1        ;integer part of Delta in y1

 move b0, y0                     ;unsigned fractional Delta in y0
 clr a #0, n1                    ;initialize a and n1
 move #mask, n0                  ;set up mask value
 move #0, n2                     ;initialize n2
 move #sinep+ 1, r2              ;initialize r2 with the value r1+ 1

 jsr sineg                       ;jump to subroutine

 sineg move a0, b                ;fraction part of ptr in b1, b0= 0 (1)
 lsr b y:( r1+ n1), x0           ;b1= signed fr. Delta, x0= sine (2)
 move b1, x1 y:( r2+ n2), b      ;sign. fract. in x1, sine in b1 (2)
 sub x0, b                       ;subtr sines to obtain slope (1)
 move b, x0 y:( r1+ n1), b       ;slope value to x0, sine in b1 (2)
 macr x0, x1, b                  ;sample approximation = m* x+ b (1)
 add y, a b, y:( r4)             ;update calculation, output sample (1)
 move n0, x1                     ;set up mask value in x1 (1)
 and x1, a                       ;mask a1 = modulo arithmetic (1)
 move a1, n1                     ;update offset register n1 (1)
 move a1, n2                     ;update offset register n2 (1)
 rts                             ;return from the subroutine (1)
 end                             ;the end of the routine (2)