From 17962801a0d1b9c8334ea98c5fbe0f991bcee037 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 10 Jun 2021 21:43:36 -0600 Subject: [PATCH] Remove redundant flag fix-ups --- include/optimizer.hpp | 2 +- src/6502-c++.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/optimizer.hpp b/include/optimizer.hpp index 86bce59..40cb83b 100644 --- a/include/optimizer.hpp +++ b/include/optimizer.hpp @@ -262,7 +262,7 @@ bool optimize(std::vector &instructions, [[maybe_unused]] const Persona if (instructions[op].opcode == mos6502::OpCode::lda || instructions[op].opcode == mos6502::OpCode::bcc || instructions[op].opcode == mos6502::OpCode::bcs || instructions[op].opcode == mos6502::OpCode::ldy || instructions[op].opcode == mos6502::OpCode::inc || instructions[op].opcode == mos6502::OpCode::clc - || instructions[op].opcode == mos6502::OpCode::sec) { + || instructions[op].opcode == mos6502::OpCode::sec || instructions[op].text.starts_with("; Handle N / S")) { if (instructions[op - 1].text == "; END remove if next is lda, bcc, bcs, ldy, inc, clc, sec" || (instructions[op - 2].text == "; END remove if next is lda, bcc, bcs, ldy, inc, clc, sec" && instructions[op - 1].type == ASMLine::Type::Directive)) { diff --git a/src/6502-c++.cpp b/src/6502-c++.cpp index 90059c6..2b8ad9d 100644 --- a/src/6502-c++.cpp +++ b/src/6502-c++.cpp @@ -285,6 +285,7 @@ void indirect_store(std::vector &instructions, std::string s_set = fmt::format("s_set_{}", location); std::string s_clear = fmt::format("s_clear_{}", location); + instructions.emplace_back(ASMLine::Type::Directive, "; Handle N / S flags from AVR"); instructions.emplace_back(mos6502::OpCode::bmi, Operand(Operand::Type::literal, n_set)); instructions.emplace_back(mos6502::OpCode::bvs, Operand(Operand::Type::literal, s_set)); instructions.emplace_back(mos6502::OpCode::jmp, Operand(Operand::Type::literal, s_clear));