Skip to content

Commit b939c39

Browse files
committed
Fix GlobalBase: $0106 to account for entry code at $0100
The entry code (cl + hl = 6 bytes) occupies $0100-$0105. Globals start at $0106. GlobalBase was $0100, causing global variable writes to overwrite the entry code. Programs now halt cleanly after execution (exit 0 instead of crashing on underflow after return from init). https://claude.ai/code/session_01GjUB9bjxa8QP7xoSqqGJWz
1 parent ef1f2f7 commit b939c39

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

pas/ob/org.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ implementation
134134
uses sysutils;
135135

136136
const
137-
GlobalBase = $0100;
137+
GlobalBase = $0106; { $100 + 6 bytes for entry code (cl + hl) }
138138

139139
var
140140
strbuf: array[0..maxStrx-1] of char;

pas/ob/orp2.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ begin
10541054
org.WrLn('');
10551055
Declarations(dc); org.SetDataSize((dc + 3) div 4 * 4);
10561056
org.WrComment('jump to module body (entry point)');
1057-
org.WrLn('cl >' + modid + '_init hl');
1057+
org.WrLn('cl >' + modid + '_init'); org.WrLn('hl');
10581058
if org.varsize > 0 then begin
10591059
org.WrComment('reserve ' + IntToStr(org.varsize) + ' bytes for global variables');
10601060
org.WrLbl('_globals');

0 commit comments

Comments
 (0)