'--------------------------------------------------------------------------------------------------------- 'CPI LMM. 'Reordered instructions to hit the hub's sweet spot cpi_lmm rdword address, h_reg 'data_8 = [HL] call #read_memory_byte add address, #1 wrword address, h_reg and flags, #carry_bit 'Keep carry flag or flags, #neg_bit 'Always set negative flag rdbyte alu, a_reg mov aux, alu 'Keep a copy in aux for later sub alu, data_8 wz rdword data_16, b_reg muxz flags, #zero_bit 'Set zero flag if SUB was zero sub data_16, #1 wz wrword data_16, b_reg 'BC = BC - 1 muxnz flags, #parity_bit 'Set parity flag if BC was non zero test alu, #$80 wz muxnz flags, #sign_bit 'Set sign flag if alu bit #7 is set xor aux, alu xor aux, data_8 and aux, #aux_bit 'Mask the auxiliary flag or flags, aux jmp #fetch '--------------------------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------------------------- 'CPD LMM. 'Reordered instructions to hit the hub's sweet spot cpd_lmm rdword address, h_reg 'data_8 = [HL] call #read_memory_byte sub address, #1 wrword address, h_reg and flags, #carry_bit 'Keep carry flag or flags, #neg_bit 'Always set negative flag rdbyte alu, a_reg mov aux, alu 'Keep a copy in aux for later sub alu, data_8 wz rdword data_16, b_reg muxz flags, #zero_bit 'Set zero flag if SUB was zero sub data_16, #1 wz wrword data_16, b_reg 'BC = BC - 1 muxnz flags, #parity_bit 'Set parity flag if BC was non zero test alu, #$80 wz muxnz flags, #sign_bit 'Set sign flag if alu bit #7 is set xor aux, alu xor aux, data_8 and aux, #aux_bit 'Mask the auxiliary flag or flags, aux jmp #fetch '--------------------------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------------------------- 'CPIR LMM. cpir_lmm rdword hl_temp, h_reg rdbyte de_temp, a_reg 'Abused to keep the accumulator rdword bc_temp, b_reg :loop mov address, hl_temp call #read_memory_byte mov alu, de_temp mov aux, alu sub alu, data_8 wz add hl_temp, #1 'Advance the pointer sub bc_temp, #1 'Decrement counter... if_nz mov bc_temp, bc_temp wz 'If alu - data_8 is non zero, is BC zero now? if_nz sub lmm_pc, #(9*4) 'Loop if both are non zero and flags, #carry_bit 'Keep carry flag or flags, #neg_bit 'Always set the negative flag mov bc_temp, bc_temp wz muxnz flags, #parity_flag xor aux, alu xor aux, data_8 and aux, #aux_bit 'Mask the auxiliary flag or flags, aux and alu, #$ff wz muxz flags, #zero_bit 'Set zero flag if alu is zero test alu, #$80 wz muxnz flags, #sign_bit 'Set sign flag if alu bit #7 is set wrword hl_temp, h_reg 'Update the registers wrword bc_temp, b_reg jmp #fetch '--------------------------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------------------------- 'CPDR LMM. cpdr_lmm rdword hl_temp, h_reg rdbyte de_temp, a_reg 'Abused to keep the accumulator rdword bc_temp, b_reg :loop mov address, hl_temp call #read_memory_byte mov alu, de_temp mov aux, alu sub alu, data_8 wz sub hl_temp, #1 'Advance the pointer sub bc_temp, #1 'Decrement counter... if_nz mov bc_temp, bc_temp wz 'If alu - data_8 is non zero, is BC zero now? if_nz sub lmm_pc, #(9*4) 'Loop if both are non zero and flags, #carry_bit 'Keep carry flag or flags, #neg_bit 'Always set the negative flag mov bc_temp, bc_temp wz muxnz flags, #parity_flag xor aux, alu xor aux, data_8 and aux, #aux_bit 'Mask the auxiliary flag or flags, aux and alu, #$ff wz muxz flags, #zero_bit 'Set zero flag if alu is zero test alu, #$80 wz muxnz flags, #sign_bit 'Set sign flag if alu bit #7 is set wrword hl_temp, h_reg 'Update the registers wrword bc_temp, b_reg jmp #fetch '---------------------------------------------------------------------------------------------------------