'--------------------------------------------------------------------------------------------------------- 'CPI LMM. cpi_lmm rdword address, h_reg 'data_8 = [HL] call #read_memory_byte add address, #1 wrword address, h_reg rdbyte alu, a_reg rdword data_16, b_reg sub data_16, #1 wz muxnz flags, #parity_bit wrword data_16, b_reg 'BC = BC - 1 mov aux, alu sub alu, data_8 xor aux, alu xor aux, data_8 test aux, #aux_bit wz muxnz flags, #aux_bit or flags, #neg_bit 'Always set the negative flag and alu, #$ff wz muxz flags, #zero_bit jmp #fetch '--------------------------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------------------------- 'CPD LMM. cpd_lmm rdword address, h_reg 'data_8 = [HL] call #read_memory_byte sub address, #1 wrword address, h_reg rdbyte alu, a_reg rdword data_16, b_reg sub data_16, #1 wz muxnz flags, #parity_bit wrword data_16, b_reg 'BC = BC - 1 mov aux, alu sub alu, data_8 xor aux, alu xor aux, data_8 test aux, #aux_bit wz muxnz flags, #aux_bit or flags, #neg_bit 'Always set the negative flag and alu, #$ff wz muxz flags, #zero_bit 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 wz 'Decrement counter... if_nz and alu, #$ff wz if_nz sub lmm_pc, #(9*4) xor aux, alu 'Final comparison xor aux, data_8 test aux, #aux_bit wz muxnz flags, #aux_bit andn flags, #parity_bit 'Always clear parity flag, as BC is 0 or flags, #neg_bit 'Always set the negative flag and alu, #$ff wz muxz flags, #zero_bit 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 wz 'Decrement counter... if_nz and alu, #$ff wz if_nz sub lmm_pc, #(9*8) xor aux, alu 'Final comparison xor aux, data_8 test aux, #aux_bit wz muxnz flags, #aux_bit andn flags, #parity_bit 'Always clear parity flag, as BC is 0 or flags, #neg_bit 'Always set the negative flag and alu, #$ff wz muxz flags, #zero_bit wrword hl_temp, h_reg 'Update the registers wrword bc_temp, b_reg jmp #fetch '---------------------------------------------------------------------------------------------------------