mirror of
https://github.com/lefticus/6502-cpp.git
synced 2024-12-22 01:30:03 +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!
|
// someone just loaded lda with a different value, so we need to abort!
|
||||||
break;
|
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
|
// abort at label
|
||||||
if (instructions[next_op].type == ASMLine::Type::Label) { break; }
|
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) {
|
if (instructions[op].opcode == mos6502::OpCode::ldy && instructions[op].op.type == Operand::Type::literal) {
|
||||||
auto op2 = op + 1;
|
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
|
// while inside this label
|
||||||
if (instructions[op2].opcode == mos6502::OpCode::ldy) {
|
if (instructions[op2].opcode == mos6502::OpCode::ldy) {
|
||||||
|
|
||||||
|
@ -41,10 +41,19 @@ std::vector<std::uint8_t> execute_c64_program(const std::string_view &name,
|
|||||||
return "unknown";
|
return "unknown";
|
||||||
}();
|
}();
|
||||||
|
|
||||||
const auto source_filename{ fmt::format("{}{}.cpp", name, optimization_level) };
|
const auto optimize_6502_name = [&]() -> std::string_view {
|
||||||
const auto vice_script_filename{ fmt::format("{}{}-vice_script", name, optimization_level) };
|
switch (o6502) {
|
||||||
const auto prg_filename{ fmt::format("{}{}.prg", name, optimization_level) };
|
case Optimize6502::Enabled: return "-optimize";
|
||||||
const auto ram_dump_filename{ fmt::format("{}{}-ram_dump", name, optimization_level) };
|
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