mirror of
https://github.com/lefticus/6502-cpp.git
synced 2024-12-22 01:30:03 +00:00
Add NOP support and allow for unused symbols
This commit is contained in:
parent
f64fa3cce6
commit
49d68fe54c
@ -5,9 +5,6 @@
|
|||||||
|
|
||||||
struct mos6502 : ASMLine
|
struct mos6502 : ASMLine
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum class OpCode {
|
enum class OpCode {
|
||||||
unknown,
|
unknown,
|
||||||
|
|
||||||
@ -41,6 +38,8 @@ struct mos6502 : ASMLine
|
|||||||
ldy,
|
ldy,
|
||||||
lsr,
|
lsr,
|
||||||
|
|
||||||
|
nop,
|
||||||
|
|
||||||
ORA,
|
ORA,
|
||||||
|
|
||||||
pha,
|
pha,
|
||||||
@ -92,6 +91,7 @@ struct mos6502 : ASMLine
|
|||||||
case OpCode::ldx:
|
case OpCode::ldx:
|
||||||
case OpCode::ldy:
|
case OpCode::ldy:
|
||||||
case OpCode::lsr:
|
case OpCode::lsr:
|
||||||
|
case OpCode::nop:
|
||||||
case OpCode::ORA:
|
case OpCode::ORA:
|
||||||
case OpCode::pha:
|
case OpCode::pha:
|
||||||
case OpCode::php:
|
case OpCode::php:
|
||||||
@ -144,6 +144,7 @@ struct mos6502 : ASMLine
|
|||||||
case OpCode::ldx:
|
case OpCode::ldx:
|
||||||
case OpCode::ldy:
|
case OpCode::ldy:
|
||||||
case OpCode::lsr:
|
case OpCode::lsr:
|
||||||
|
case OpCode::nop:
|
||||||
case OpCode::ORA:
|
case OpCode::ORA:
|
||||||
case OpCode::pha:
|
case OpCode::pha:
|
||||||
case OpCode::php:
|
case OpCode::php:
|
||||||
@ -229,6 +230,7 @@ struct mos6502 : ASMLine
|
|||||||
case OpCode::bpl: return "bpl";
|
case OpCode::bpl: return "bpl";
|
||||||
case OpCode::bcc: return "bcc";
|
case OpCode::bcc: return "bcc";
|
||||||
case OpCode::bcs: return "bcs";
|
case OpCode::bcs: return "bcs";
|
||||||
|
case OpCode::nop: return "nop";
|
||||||
case OpCode::unknown: return "";
|
case OpCode::unknown: return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +114,8 @@ struct AVR : ASMLine
|
|||||||
|
|
||||||
mov,
|
mov,
|
||||||
|
|
||||||
|
nop,
|
||||||
|
|
||||||
out,
|
out,
|
||||||
|
|
||||||
pop,
|
pop,
|
||||||
@ -190,6 +192,7 @@ struct AVR : ASMLine
|
|||||||
if (o == "in") { return OpCode::in; }
|
if (o == "in") { return OpCode::in; }
|
||||||
if (o == "out") { return OpCode::out; }
|
if (o == "out") { return OpCode::out; }
|
||||||
if (o == "inc") { return OpCode::inc; }
|
if (o == "inc") { return OpCode::inc; }
|
||||||
|
if (o == "nop") { return OpCode::nop; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw std::runtime_error(fmt::format("Unknown opcode: {}", o));
|
throw std::runtime_error(fmt::format("Unknown opcode: {}", o));
|
||||||
@ -726,6 +729,10 @@ void translate_instruction(const Personality &personality,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case AVR::OpCode::nop: {
|
||||||
|
instructions.emplace_back(mos6502::OpCode::nop);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case AVR::OpCode::unknown: {
|
case AVR::OpCode::unknown: {
|
||||||
throw std::runtime_error("Could not translate 'unknown' instruction");
|
throw std::runtime_error("Could not translate 'unknown' instruction");
|
||||||
}
|
}
|
||||||
@ -955,8 +962,8 @@ std::vector<mos6502> run(const Personality &personality, std::istream &input)
|
|||||||
try {
|
try {
|
||||||
i.text = new_labels.at(i.text);
|
i.text = new_labels.at(i.text);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
spdlog::error("Error looking up label name: '{}'", i.text);
|
spdlog::warn("Unused label: '{}', consider making function static until we remove unused functions", i.text);
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ quit
|
|||||||
|
|
||||||
|
|
||||||
REQUIRE(system(fmt::format("{} -f {} -t C64 {}", mos6502_cpp_executable, source_filename, optimization_level).c_str()) == EXIT_SUCCESS);
|
REQUIRE(system(fmt::format("{} -f {} -t C64 {}", mos6502_cpp_executable, source_filename, optimization_level).c_str()) == EXIT_SUCCESS);
|
||||||
REQUIRE(system(fmt::format("xvfb-run {} +saveres -warp -moncommands {}", x64_executable, vice_script_filename).c_str()) == EXIT_SUCCESS);
|
REQUIRE(system(fmt::format("xvfb-run -d {} +saveres -warp -moncommands {}", x64_executable, vice_script_filename).c_str()) == EXIT_SUCCESS);
|
||||||
|
|
||||||
std::ifstream memory_dump(ram_dump_filename, std::ios::binary);
|
std::ifstream memory_dump(ram_dump_filename, std::ios::binary);
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ TEST_CASE("Can write to screen memory via function call")
|
|||||||
R"(
|
R"(
|
||||||
|
|
||||||
void poke(unsigned int location, unsigned char value) {
|
void poke(unsigned int location, unsigned char value) {
|
||||||
*reinterpret_cast<volatile unsigned char *>(location) = 10;
|
*reinterpret_cast<volatile unsigned char *>(location) = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -109,7 +109,7 @@ int main()
|
|||||||
const auto result = execute_c64_program("write_to_screen_memory_via_function", program, o_level, 0x400, 0x401);
|
const auto result = execute_c64_program("write_to_screen_memory_via_function", program, o_level, 0x400, 0x401);
|
||||||
|
|
||||||
REQUIRE(result.size() == 2);
|
REQUIRE(result.size() == 2);
|
||||||
CHECK(result[0] == 10);
|
|
||||||
CHECK(result[0] == 11);
|
|
||||||
|
|
||||||
|
CHECK(result[0] == 10);
|
||||||
|
CHECK(result[1] == 11);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user