From f0e676facb60d5890ea204aa75bb1e00f0aa325c Mon Sep 17 00:00:00 2001 From: CrazyEttin <> Date: Thu, 15 Sep 2022 22:26:30 +0300 Subject: [PATCH] Fix a bug with non-initial ORG statements in the assembler --- assembler.pas | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assembler.pas b/assembler.pas index 7b58a79..4a6da48 100644 --- a/assembler.pas +++ b/assembler.pas @@ -170,6 +170,7 @@ begin LP := 1; BP := 0; SP := 0; + EP := 0; //Begin the main loop repeat @@ -264,7 +265,9 @@ begin DatOrg := ExtractWord (2, Line, [' ']); try if Hex2Dec (DatOrg) <=$ffff then begin + if BP > EP then EP := BP; BP := Hex2Dec (DatOrg); + if BP < SP then SP := BP; end else ArgError; except @@ -434,7 +437,7 @@ begin if AllRefsResolved = false then halt (1); //Set the end pointer and reset the byte pointer to the start of the program - EP := BP; + if BP > EP then EP := BP; BP := SP; //Write the program file