******************************************************************************* * * * CHECK FOR DUPLICATE CYCLES * * 04/20/13 * * * * This C64 subroutine checks for duplicate cycles. The calling sequence of * * the subroutine is; * * * * gop (packed (L+2K,K) value) => a4 * * MINP[0] (MSW of current minimum) => b4 * * MINP[1] (LSW of current minimum) => a6 * * address of gom (previous packed (L+2K,K) and minimum values) => b6 * * gomind (number of previous values) => a8 * * * * A return value of 0 indicates that the cycle is a duplicate. * * * ******************************************************************************* .global _check _check: ldw.d2 *b6++[2], a9 ; load gom || add.l1x b6, 4, a3 ; load address of gom[1] || sub.l2x a8, 1, b2 ; load loop count || addab.d1 a4, 0, a7 ; save gop || mvk.s1 1, a4 ; set flag || mvk.s2 1, b0 ; set flag ldw.d1 *a3++[3], b5 ; load MIN[0] || ldw.d2 *b6++[1], a5 ; load MIN[1] ldw.d2 *b6++[2], a9 ; load gom || bdec.s2 aloop, b2 ; conditional branch to loop beginning ldw.d1 *a3++[3], b5 ; load MIN[0] || ldw.d2 *b6++[1], a5 ; load MIN[1] ldw.d2 *b6++[2], a9 ; load gom || bdec.s2 aloop, b2 ; conditional branch to loop beginning cmpeq.l1 a9, a7, a1 ; compare gom to gop || ldw.d1 *a3++[3], b5 ; load MIN[0] || ldw.d2 *b6++[1], a5 ; load MIN[1] || zero.l2 b1 ; clear flag **************** * begin loop * **************** aloop: [a1] cmpeq.l2 b5, b4, b1 ; compare MIN[0] to MINP[0] || [a1] cmpeq.l1 a5, a6, a2 ; compare MIN[1] to MINP[1] || and.s1x b1, a2, a0 ; "and" conditions || ldw.d2 *b6++[2], a9 ; load gom || [b0] bdec.s2 aloop, b2 ; conditional branch to loop beginning [a0] mpy.m1 a4, 0, a4 ; clear flag ||[!a1] zero.l2 b1 ; clear flag || [a0] zero.s2 b0 ; clear flag || cmpeq.l1 a9, a7, a1 ; compare gom to gop || ldw.d1 *a3++[3], b5 ; load MIN[0] || ldw.d2 *b6++[1], a5 ; load MIN[1] ************** * end loop * ************** b.s2 b3 ; return || and.s1x b1, a2, a0 ; "and" conditions [a0] mpy.m1 a4, 0, a4 ; clear flag nop 4 .end