	.section .text.m0, "ax"
	.file	"freOffCompAsm.m0.asm"
	// DO NOT MODIFY THE CONTENT ABOVE
	.global freOffCompAsm
freOffCompAsm:

	R1: M[0] -> BIU1.T0;
	NOP;
	NOP;
	NOP;
	NOP;
	BIU1: Load(T0)(A++) -> M[20];
	BIU1: Load(T0)(A++) -> M[1];                                     								// input signal
	BIU1: Load(T0)(A++) -> M[2];                                           							// fre_offfset_est
	BIU1: Load(T0)(A++) -> M[3];																	// outputAddr

	IMA0: V(512) -> IMA0.T0(Mode0);NOP;
	IMA0: VHigh(T0,0) -> IMA0.T0(Mode0);NOP;
	IMA0: SetShiftMode(T0)-> ShiftMode0(Mode0);NOP;

	R5: PreConfig(M[20]);
	R5: WriteConf(Mfetch) -> KI[0-15](Mode0);

	R4: M[1] -> BIU0.T0(Mode0);
	R5: M[2] -> BIU1.T1(Mode0);
	R3: M[3] -> BIU3.T3(Mode0);
	NOP;NOP;NOP;
	BIU0: Load(T0) -> IMA0.T3(Mode0);
	BIU1: Load(T1) -> IMA0.T2(Mode0);
	MFetch: REPEAT @(10);

	MFetch: Lpto %ENDFRECOMP @(KI0);
		IMA0: 0 + T2*T3(ShiftMode0)(C)(S)(SSS) -> IMA0.MR;
		MFetch: REPEAT @(15);
		BIU0: Load(T0) -> IMA0.T3(Mode0);
		BIU1: Load(T1) -> IMA0.T2(Mode0);

		IMA0: ReadMR(L) -> IMA1.T0;                 // real
		IMA0: ReadMR(H) -> IMA2.T0;                 // imag
		MFetch: REPEAT @(4);

		IMA1: T0 >> 10(W) -> IMA0.T1 || IMA2: T0 >> 10(W) -> IMA2.T1;
		MFetch: REPEAT @(2);

		IMA0: CPRS(T1)(CprsMode1) -> IMA2.T2 || IMA2: CPRS(T1)(CprsMode1) -> IMA2.T3;
		MFetch: REPEAT @(4);

		IMA2: T3 << 16(W)(U) -> IMA2.T3;
		NOP;NOP;
		IMA2: T2 + T3(W) -> BIU3.T1;
		NOP;NOP;
		BIU3: Store(T1,T3)(A++);

	ENDFRECOMP:

		MFetch: REPEAT @(10);
		MFetch:MPU.STOP;
