From a04c937aeb2a8a0dc4b0a5e31781b20a646794ba Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 21 May 2021 12:02:48 -0600 Subject: [PATCH] Faster 16bit increment for index operations --- src/6502-c++.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/6502-c++.cpp b/src/6502-c++.cpp index 7d60862..19025ea 100644 --- a/src/6502-c++.cpp +++ b/src/6502-c++.cpp @@ -315,14 +315,12 @@ void subtract_16_bit(const Personality &personality, void increment_16_bit(const Personality &personality, std::vector &instructions, int reg) { - // instructions.emplace_back(mos6502::OpCode::sta, Operand(Operand::Type::literal, address_low_byte)); - instructions.emplace_back(mos6502::OpCode::lda, personality.get_register(reg)); - instructions.emplace_back(mos6502::OpCode::clc); - instructions.emplace_back(mos6502::OpCode::adc, Operand(Operand::Type::literal, "#1")); - instructions.emplace_back(mos6502::OpCode::sta, personality.get_register(reg)); - instructions.emplace_back(mos6502::OpCode::lda, personality.get_register(reg + 1)); - instructions.emplace_back(mos6502::OpCode::adc, Operand(Operand::Type::literal, "#0")); - instructions.emplace_back(mos6502::OpCode::sta, personality.get_register(reg + 1)); + std::string skip_high_byte_label = + "skip_inc_high_byte_" + std::to_string(instructions.size()); + instructions.emplace_back(mos6502::OpCode::inc, personality.get_register(reg)); + instructions.emplace_back(mos6502::OpCode::bne, Operand(Operand::Type::literal, skip_high_byte_label)); + instructions.emplace_back(mos6502::OpCode::inc, personality.get_register(reg+1)); + instructions.emplace_back(ASMLine::Type::Label, skip_high_byte_label); } void translate_instruction(const Personality &personality,