From a6f012878e9ddc17d0798ad91b9b1d95b09c7b32 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 12 May 2021 07:51:58 -0600 Subject: [PATCH] Add 'call' instruction --- src/6502-c++.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/6502-c++.cpp b/src/6502-c++.cpp index b232b80..36e29e6 100644 --- a/src/6502-c++.cpp +++ b/src/6502-c++.cpp @@ -95,6 +95,7 @@ struct AVR : ASMLine brne, brsh, + call, clr, com, cp, @@ -155,6 +156,7 @@ struct AVR : ASMLine if (o == "rol") { return OpCode::rol; } if (o == "ror") { return OpCode::ror; } if (o == "rcall") { return OpCode::rcall; } + if (o == "call") { return OpCode::call; } if (o == "ld") { return OpCode::ld; } if (o == "sub") { return OpCode::sub; } if (o == "subi") { return OpCode::subi; } @@ -355,9 +357,19 @@ void translate_instruction(const Personality &personality, std::vector case AVR::OpCode::ror: instructions.emplace_back(mos6502::OpCode::ror, personality.get_register(o1_reg_num)); return; + case AVR::OpCode::call: + if (o1.value != ".") { + instructions.emplace_back(mos6502::OpCode::jsr, o1); + return; + } + throw std::runtime_error("Unhandled call"); case AVR::OpCode::rcall: if (o1.value != ".") { instructions.emplace_back(mos6502::OpCode::jsr, o1); + } else { + // just push in 2 bytes + instructions.emplace_back(mos6502::OpCode::pha); + instructions.emplace_back(mos6502::OpCode::pha); } return;