



; 	metrowerks sample code



	section		rtlib
	org p:
 
	global Fasmdoublerelay

	SUBROUTINE "Fasmdoublerelay",Fasmdoublerelay,FasmdoublerelayEND-Fasmdoublerelay

 Fasmdoublerelay:
  		
  		adda	#2,SP		;allocation the memory
		move.w 	y0,A		;save the first parameter (DeltaT) to the register A
		move.w	X:(R2)+,B	;save the second parameter (epsilon_T) to the register B
		move.w	#0,X:(SP)	;save the value 0 to the memory
				
		cmp		B,A			;compare registers A-B (DeltaT - epsilon_T) and update the CCR registers		
		bgt		<skok1		;if A>B (DeltaT > epsilon_T) jump to target address skok1 
		nop					;increment the program counter, no operation syntax
				
		cmp		X:(SP),A	;compare the register A-(memory space) (DeltaT - 0) and update the CCR registers
		bge		<skok2		;if A>=(memory space) (DeltaT >= 0) jump to target address skok2 
		nop					;increment the program counter, no operation syntax
				
		cmp		X:(SP),A	;compare the register A-memory space (DeltaT - 0) and update the CCR registers
		blt		<skok3		;if A<(memory space) (DeltaT < 0) jump to target address skok3
		nop					;increment the program counter, no operation syntax
				
		neg		B			;negate the register B (-epsilon_T)
		cmp		A,B			;compare registers A-B (DeltaT - epsilon_T) and update the CCR registers
		blt		<skok3		;if A<B (DeltaT < -epsilon_T) jump to target address skok3 
		nop					;increment the program counter, no operation syntax
				
		move.w	X:(R2),y0	;output is the last value saved in register R2		
		suba	#2,SP		;dealocation the memory
		rts					;return from a call to a subroutine
		
skok1						;target address skok1
		move.w	#4,y0		;output is 4
		move.w	y0,X:(R2)	;save the output value 1 to the register R2
		suba	#2,SP		;dealocation the memory
		rts					;return from a call to a subroutine

skok2						;target address skok2
		move.w	#2,y0		;outpu is 2
		move.w	y0,X:(R2)	;save the output value 1 to the register R2
		suba	#2,SP		;dealocation the memory
		rts					;return from a call to a subroutine

skok3						;target address skok3			
		move.w	#0,y0		;oputput is 2	
		move.w	y0,X:(R2)	;save the output value 1 to the register R2
		suba	#2,SP		;dealocation the memory
		rts					;return from a call to a subroutine
				 	
 FasmdoublerelayEND:
 
 	endsec
 	
	end
