



; 	metrowerks sample code



	section		rtlib
	org p: 
	
	global Fasmrelay

	SUBROUTINE "Fasmrelay",Fasmrelay,FasmrelayEND-Fasmrelay

 Fasmrelay:
 		
		move.w 	y0,A		;save the first parameter (DeltaPsi) to the register A
		move.w  X:(R2)+,B	;save the second parameter (epsilon_Psi) to the register B
						
		cmp		B,A			;compare the registers A-B (DeltaPsi - epsilon_Psi) and update the CCR registers  
		bge		<skok1		;if A>=B (DeltaPsi >= epsilon_Psi) jump to target address skok1
		nop					;increment the program counter, no operation syntax
		neg		B			;negate the B register (-epsilon_Psi)
		cmp		B,A			;compare the registers A-B (DeltaPsi - epsilon_Psi) and update the CCR registers
		ble		<skok2		;if A<=-B (DeltaPsi <= -epsilon_Psi) jump to target address skok2
		nop					;increment the program counter, no operation syntax

		move.w	X:(R2),y0	;output is the last value saved in register R2
		rts					;return from a call to a subroutine
				
skok1						;target address skok1
		move.w	#1,y0		;output is 1
		move.w	y0,X:(R2)	;save the output value 1 to the register R2
		rts					;return from a call to a subroutine

skok2						;target address skok2
		move.w	#0,y0		;output is 0
		move.w	y0,X:(R2)	;save the output value 0 to the register R2
		rts					;return from a call to a subroutine
			 	
 FasmrelayEND:
 
 	endsec
 	
	end
