;*******************************************************************************
; C H A M E L E O N   DSP Assembler file                                       *
;*******************************************************************************
; Copyright (C) 2001-2002 Soundart                                             *
; www.soundart-hot.com                                                         *
; support@soundart-hot.com                                                     *
;*******************************************************************************
; Modified by Aleix Riera
; aleix@fjarre.com
; www.fjarre.com/~aleix
;*******************************************************************************
;
; MODULE: Addk (ONLY 1 SAMPLE / BUFFER_SIZE)
;	This block of code adds a constant value to the input buffer:
;
;	output[i] = input[i] + K
;
; ARGUMENTS:
;	(X)   = In		- Input sample (Y)
;	(X+1) = Out		- Output sample (Y)
;	(X+2) = Constant	- Constant to add
;
;******************************************************************************
module_addk:
	define	R_In			'R5'
	define	R_Out			'R1'

;===============================CODE=====================================

	MOVE	X:(R_X)+,R_In		; (X)   = In (Y)
	MOVE	X:(R_X)+,R_Out		; (X+1) = Out (Y)
	MOVE	X:(R_X),X0		; (X+2) = Constant

	TFR	X0,A
	MOVE			Y:(R_In),Y0
	
	;.LOOP	#BUFFER_SIZE
	;----------------------------------------------------------------
	  ADD	Y0,A		Y:(R_In)+,Y0
	  NOP
	  TFR	X0,A		A,Y:(R_Out)+
	;----------------------------------------------------------------
	;.ENDL

;===============================CODE=====================================

	undef	R_In
	undef	R_Out

	RTS