NOP 5
WAIT_SPI_START_LOOP: LOAD SPI_0 R0
LOAD BUFFERED_SPI_0 R1
EQUAL WAIT_SPI_START_LOOP R0 R1
STORE BUFFERED_SPI_0 R0
LOAD SPI_1 R0
CONST 7 R2
ANL R2 R0
HFIX R0
LOAD SPI_1 R0
CONST 16 R2
ANL R2 R0
EQUAL0 HANDLER0_PROC R0
JUMP HANDLER1_PROC
HANDLER0_PROC: LOAD SPI_1 R0
CONST 8 R2
ANL R0 R2
EQUAL0 EXIT_WAIT_NEG R2
CONST 1 R0
WAIT_NEG_LOOP: LOAD32 HAND1_L R1
ANL R0 R1
LOAD PREV_EX_REF R2
STORE PREV_EX_REF R1
SUB R2 R1
EQUAL EXIT_WAIT_NEG R0 R1
JUMP WAIT_NEG_LOOP
EXIT_WAIT_NEG: CONST 0 R0 // REL_ADDRESS
CONST 63 R1 // LEN
LOOP: MOVE R0 R3
ADD R1 R3
CFIX1 R3
LOAD num_wait_samples R4
WAIT0_SAMPLES: WAIT_OWN_HAND
DJNZ WAIT0_SAMPLES R4
LOAD32 HAND1_L R3
CSTORE32 TAPBUF_0 R3
DJNZ LOOP R1
LOAD CONST_50 R0 // REL_ADDRESS CF 80+127
LOAD CONST_7F R1 // LEN
LOOP2: MOVE R0 R3
ADD R1 R3
CFIX1 R3
LOAD num_wait_samples R4
WAIT1_SAMPLES: WAIT_OWN_HAND
DJNZ WAIT1_SAMPLES R4
LOAD32 HAND1_L R3
CSTORE32 TAPBUF_0 R3
DJNZ LOOP2 R1
LOAD BUFFERED_SPI_0 R0
STORE TO_OUT_READY R0
JUMP WAIT_SPI_START_LOOP
HANDLER1_PROC: LOAD SPI_1 R0
CONST 8 R2
ANL R0 R2
EQUAL0 EXIT_WAIT_NEG_H2 R2
CONST 1 R0
WAIT_NEG_LOOP_H2: LOAD32 HAND2_L R1
ANL R0 R1
LOAD PREV_EX_REF R2
STORE PREV_EX_REF R1
SUB R2 R1
EQUAL EXIT_WAIT_NEG_H2 R0 R1
JUMP WAIT_NEG_LOOP_H2
EXIT_WAIT_NEG_H2: CONST 0 R0 // REL_ADDRESS
CONST 63 R1 // LEN
LOOP_H2: MOVE R0 R3
ADD R1 R3
CFIX1 R3
LOAD num_wait_samples R4
WAIT2_SAMPLES: WAIT_OWN_HAND
DJNZ WAIT2_SAMPLES R4
LOAD32 HAND2_L R3
CSTORE32 TAPBUF_0 R3
DJNZ LOOP_H2 R1
LOAD CONST_50 R0 // REL_ADDRESS CF 80+127
LOAD CONST_7F R1 // LEN
LOOP2_H2: MOVE R0 R3
ADD R1 R3
CFIX1 R3
LOAD num_wait_samples R4
WAIT3_SAMPLES: WAIT_OWN_HAND
DJNZ WAIT3_SAMPLES R4
LOAD32 HAND2_L R3
CSTORE32 TAPBUF_0 R3
DJNZ LOOP2_H2 R1
LOAD BUFFERED_SPI_0 R0
STORE TO_OUT_READY R0
JUMP WAIT_SPI_START_LOOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
