Emulator learnings folded back into decompiler
This commit is contained in:
@@ -32,6 +32,13 @@ class SerialReconstructionIntegrationTest(unittest.TestCase):
|
||||
0x3038: ins(0x3038, "MOV:G.B", "R0, @SCI1_TDR", [0xFEDB]),
|
||||
0x303C: ins(0x303C, "ADD:Q.B", "#1, @H'F9C2", [0xF9C2]),
|
||||
0x3040: ins(0x3040, "CMP:G.B", "#6, @H'F9C2", [0xF9C2]),
|
||||
0xBEEA: ins(0xBEEA, "BCLR.B", "#5, @FRT1_TCSR", [0xFE91]),
|
||||
0xBEEE: ins(0xBEEE, "TST.B", "@H'F9C0", [0xF9C0]),
|
||||
0xBEF4: ins(0xBEF4, "ADD:Q.B", "#-1, @H'F9C0", [0xF9C0]),
|
||||
0xBEF8: ins(0xBEF8, "TST.B", "@H'F9C1", [0xF9C1]),
|
||||
0xBEFE: ins(0xBEFE, "ADD:Q.B", "#-1, @H'F9C1", [0xF9C1]),
|
||||
0xBF02: ins(0xBF02, "TST.W", "@H'F9C6", [0xF9C6]),
|
||||
0xBF08: ins(0xBF08, "ADD:Q.W", "#-1, @H'F9C6", [0xF9C6]),
|
||||
}
|
||||
analysis = analyze_serial_reconstruction(instructions)
|
||||
|
||||
@@ -47,7 +54,11 @@ class SerialReconstructionIntegrationTest(unittest.TestCase):
|
||||
)
|
||||
self.assertIn("; Serial Protocol Reconstruction", listing)
|
||||
self.assertIn("TX candidate: 6 bytes", listing)
|
||||
self.assertIn("TX path: initial byte is written from the TX frame buffer", listing)
|
||||
self.assertIn("; Serial RAM role candidates", listing)
|
||||
self.assertIn("periodic_report_countdown", listing)
|
||||
self.assertIn("candidate/evidence-supported SCI1 6-byte TX frame", listing)
|
||||
self.assertIn("RAM role post_tx_report_delay", listing)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "out.json"
|
||||
@@ -55,14 +66,19 @@ class SerialReconstructionIntegrationTest(unittest.TestCase):
|
||||
payload = json.loads(path.read_text(encoding="utf-8"))
|
||||
|
||||
self.assertEqual(payload["serial_reconstruction"]["candidates"][0]["frame_length"], 6)
|
||||
self.assertEqual(payload["serial_reconstruction"]["candidates"][0]["tx_path"]["kind"], "interrupt_driven_txi")
|
||||
self.assertEqual(payload["serial_reconstruction"]["ram_roles"][2]["name"], "periodic_report_countdown")
|
||||
tdr_instruction = next(item for item in payload["instructions"] if item["address"] == 0x3038)
|
||||
self.assertIn("serial_reconstruction", tdr_instruction)
|
||||
timer_instruction = next(item for item in payload["instructions"] if item["address"] == 0xBF08)
|
||||
self.assertEqual(timer_instruction["serial_reconstruction"][0]["role_name"], "periodic_report_countdown")
|
||||
|
||||
pseudocode = generate_pseudocode(
|
||||
payload,
|
||||
options=PseudocodeOptions(include_addresses=False, include_asm=False, structured=False),
|
||||
)
|
||||
self.assertIn("candidate/evidence-supported SCI1 6-byte TX frame", pseudocode)
|
||||
self.assertIn("candidate/evidence-supported RAM role periodic_report_countdown", pseudocode)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user