From 48e149b29f28b1556611091d7e8235b5bd9f0b06 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Wed, 23 Oct 2024 11:11:37 +0200 Subject: [PATCH] add sign for jumps --- src/Assembleur.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Assembleur.cpp b/src/Assembleur.cpp index 2d22343..949f7ab 100644 --- a/src/Assembleur.cpp +++ b/src/Assembleur.cpp @@ -78,11 +78,17 @@ std::uint32_t Assembleur::ParseOperationImmediate( } std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, const std::string& a_Label) { - return IToInt(a_Instruction) | a_Instruction.m_Line - ParseLabel(a_Label); + int jump = a_Instruction.m_Line - ParseLabel(a_Label); + if (jump < 0) + jump = jump & 0x7FFFFFF | 0x4000000; + return IToInt(a_Instruction) | jump; } std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, std::uint8_t a_R1, std::uint8_t a_R2, const std::string& a_Label) { - return IToInt(a_Instruction) | a_R1 << 24 | a_R2 << 21 | a_Instruction.m_Line - ParseLabel(a_Label); + int jump = a_Instruction.m_Line - ParseLabel(a_Label); + if (jump < 0) + jump = jump & 0xFFFFF | 100000; + return IToInt(a_Instruction) | a_R1 << 24 | a_R2 << 21 | jump; } std::uint32_t Assembleur::ParseJump(Instruction a_Instruction) {