From daead5eaa4ad766da193d95130c1b4eae1597e66 Mon Sep 17 00:00:00 2001 From: ApfelTeeSaft <91074565+ApfelTeeSaft@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:35:45 +0200 Subject: [PATCH] basic, add calculator Z80 machine code to rom example --- ROMExample/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ROMExample/main.cpp b/ROMExample/main.cpp index cd19b77..f11349b 100644 --- a/ROMExample/main.cpp +++ b/ROMExample/main.cpp @@ -11,14 +11,14 @@ void generateCalculatorROM(const std::string& filepath) { return; } - // Program Section (First half) + // Program Section: Z80 Machine Code + // Simple calculator operations (addition and subtraction test) std::vector programData = { - 0x3E, 0x0A, // LD A, 0x0A - 0x06, 0x14, // LD B, 0x14 - 0x0E, 0x20, // LD C, 0x20 - 0x80, // ADD A, B - 0x81, // ADD A, C - 0xC9 // RET + 0x3E, 0x02, // LD A, 2 (load 2 into A) + 0x06, 0x03, // LD B, 3 (load 3 into B) + 0x80, // ADD A, B (A = A + B, i.e., A = 2 + 3 = 5) + 0xC3, 0x00, 0x10, // JP 0x1000 (jump to 0x1000 for further operations) + 0xC9 // RET (return to the caller) }; romFile.write(reinterpret_cast(programData.data()), programData.size());