mirror of
https://github.com/lefticus/6502-cpp.git
synced 2024-12-30 07:31:38 +00:00
Avoid optimizations around jsr and pla
This commit is contained in:
parent
61e3609f47
commit
8894f4b1cf
@ -64,6 +64,10 @@ bool optimize(std::vector<mos6502> &instructions, const Personality &personality
|
||||
// someone just loaded lda with a different value, so we need to abort!
|
||||
break;
|
||||
}
|
||||
// abort at pla
|
||||
if (instructions[next_op].opcode == mos6502::OpCode::pla) { break; }
|
||||
// abort at jsr
|
||||
if (instructions[next_op].opcode == mos6502::OpCode::jsr) { break; }
|
||||
|
||||
// abort at label
|
||||
if (instructions[next_op].type == ASMLine::Type::Label) { break; }
|
||||
@ -141,7 +145,8 @@ bool optimize(std::vector<mos6502> &instructions, const Personality &personality
|
||||
if (instructions[op].opcode == mos6502::OpCode::ldy && instructions[op].op.type == Operand::Type::literal) {
|
||||
auto op2 = op + 1;
|
||||
|
||||
while (op2 < instructions.size() && (instructions[op2].type != ASMLine::Type::Label)) {
|
||||
while (op2 < instructions.size() && (instructions[op2].type != ASMLine::Type::Label)
|
||||
&& (instructions[op2].opcode == mos6502::OpCode::jsr)) {
|
||||
// while inside this label
|
||||
if (instructions[op2].opcode == mos6502::OpCode::ldy) {
|
||||
|
||||
@ -163,7 +168,7 @@ bool optimize(std::vector<mos6502> &instructions, const Personality &personality
|
||||
for (size_t op = 0; op < instructions.size() - 1; ++op) {
|
||||
if (instructions[op].opcode == mos6502::OpCode::lda && instructions[op].op.type == Operand::Type::literal) {
|
||||
const auto operand = instructions[op].op;
|
||||
auto op2 = op + 1;
|
||||
auto op2 = op + 1;
|
||||
// look for multiple stores of the same value
|
||||
while (
|
||||
op2 < instructions.size()
|
||||
|
@ -41,10 +41,19 @@ std::vector<std::uint8_t> execute_c64_program(const std::string_view &name,
|
||||
return "unknown";
|
||||
}();
|
||||
|
||||
const auto source_filename{ fmt::format("{}{}.cpp", name, optimization_level) };
|
||||
const auto vice_script_filename{ fmt::format("{}{}-vice_script", name, optimization_level) };
|
||||
const auto prg_filename{ fmt::format("{}{}.prg", name, optimization_level) };
|
||||
const auto ram_dump_filename{ fmt::format("{}{}-ram_dump", name, optimization_level) };
|
||||
const auto optimize_6502_name = [&]() -> std::string_view {
|
||||
switch (o6502) {
|
||||
case Optimize6502::Enabled: return "-optimize";
|
||||
case Optimize6502::Disabled: return "-no-optimize";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}();
|
||||
|
||||
const auto source_filename{ fmt::format("{}{}{}.cpp", name, optimization_level, optimize_6502_name) };
|
||||
const auto vice_script_filename{ fmt::format("{}{}{}-vice_script", name, optimization_level, optimize_6502_name) };
|
||||
const auto prg_filename{ fmt::format("{}{}{}.prg", name, optimization_level, optimize_6502_name) };
|
||||
const auto ram_dump_filename{ fmt::format("{}{}{}-ram_dump", name, optimization_level, optimize_6502_name) };
|
||||
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user