; SineML.dsm ; L. Stewart August 24, 1982 12:54 PM C_CODE SEGMENT ASSUME CS:C_CODE, DS:C_DATA ; Generate Sine wave ; int Sine(initialphase, &SineCB); ; where SineCB is a pointer to the control block ; and Sine returns the final phase ; The control block has the fields ; destination pointer ; sample count ; frequency ; sinetable _Sine PROC NEAR MOV DI,[BX] ; destination MOV DX,CX ; initial phase MOV CX,[2+BX] ; count (bytes) OR CX,CX JZ sdone MOV SI,[4+BX] ; frequency MOV BX,[6+BX] ; sinetable CLD ; increment DI on STOSB sloop: ADD DX,SI ; phase increment MOV AL,DH ; upper 8 bits of phase are table index XLATB ; fetch from table STOSB ; store into destination and increment LOOP sloop ; decrement count and loop sdone: MOV BX,DX RET _Sine ENDP PUBLIC _Sine C_CODE ENDS END