Skip to content

Commit f06ff8b

Browse files
authored
fix: slot 5 re-entrancy bug in / command and remove unused SIZE keyword (#120)
Move IsDestructiveActionOK check out of module code (dos.asm) into warmstart.asm so it runs before slot 5 is paged in. The confirmation dialog calls EXTPrintCharacter/KNLGetSingleCharacter which do their own inc 8+5, double-incrementing slot 5 and executing from the wrong page — hanging the system. Also change jmp EXTBootXA to jsr so the wrapper's dec 8+5 properly restores slot 5 when kernel.RunNamed returns (program not found). Remove unused SIZE keyword from token table and tokeniser module.
1 parent e722209 commit f06ff8b

8 files changed

Lines changed: 34 additions & 46 deletions

File tree

modules/hardware/dos.asm

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@
1212
.section code
1313

1414
Export_EXTBootXA:
15-
pha
16-
phx
17-
jsr IsDestructiveActionOK
18-
plx
19-
pla
20-
bcc _action_ok
21-
jmp WarmStart
22-
23-
_action_ok:
2415
sta zTemp0+0
2516
stx zTemp0+1
2617

@@ -77,10 +68,6 @@ _copy_done:
7768
sta kernel.args.buf+1
7869

7970
jsr kernel.RunNamed
80-
81-
jsr ResetTokenBuffer
82-
.error_noprogram
83-
84-
jmp WarmStart
71+
rts
8572

8673
.send code

modules/kernel/commands/files/dir.asm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,15 @@ _PEPadDone:
523523
lda DIR_FLAGS,x
524524
and #DIR_ATTR_DIR
525525
beq _PENotDir
526-
; Print " <DIR>" right-aligned
526+
; Print " <dir>" right-aligned
527527
lda #32
528528
jsr EXTPrintCharacter
529529
ldx #_CDDirTag >> 8
530530
lda #_CDDirTag & $FF
531531
jsr PrintStringXA
532532
bra _PEEndLine
533533
_PENotDir:
534+
; Print right-aligned block count
534535
; Print right-aligned block count
535536
ldx dirPrintIdx
536537
ldy DIR_BLK_HI,x ; blocks hi → Y
@@ -587,7 +588,7 @@ _CDFreeMsg:
587588
_CDBlocksHdr:
588589
.text " Blocks",0
589590
_CDDirTag:
590-
.text "<DIR>",0
591+
.text "<dir>",0
591592

592593
; ************************************************************************************************
593594
;

modules/tokeniser/__kwdtext.asm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,12 @@ KeywordSet0:
100100
.text 4,$1c,"READ" ; $de READ
101101
.text 4,$2e,"RECT" ; $df RECT
102102
.text 3,$e4,"REM" ; $e0 REM
103-
.text 4,$3b,"SIZE" ; $e1 SIZE
104-
.text 5,$7b,"SOLID" ; $e2 SOLID
105-
.text 5,$89,"SOUND" ; $e3 SOUND
106-
.text 6,$d7,"SPRITE" ; $e4 SPRITE
107-
.text 4,$45,"TEXT" ; $e5 TEXT
108-
.text 2,$a3,"TO" ; $e6 TO
109-
.text 4,$3c,"STEP" ; $e7 STEP
103+
.text 5,$7b,"SOLID" ; $e1 SOLID
104+
.text 5,$89,"SOUND" ; $e2 SOUND
105+
.text 6,$d7,"SPRITE" ; $e3 SPRITE
106+
.text 4,$45,"TEXT" ; $e4 TEXT
107+
.text 2,$a3,"TO" ; $e5 TO
108+
.text 4,$3c,"STEP" ; $e6 STEP
110109
.text $FF
111110
KeywordSet1:
112111
.text 0,$65,"" ; $80 !0:EOF

source/common/cli/warmstart.asm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ _slot3ok:
4848
lda lineBuffer ; first character is slash
4949
cmp #"/"
5050
bne _WSNotSlash
51+
jsr IsDestructiveActionOK ; confirm if unsaved program (before module page-in)
52+
bcs WarmStart ; user cancelled
5153
ldx #(lineBuffer+1) >> 8 ; boot rest of line.
5254
lda #(lineBuffer+1) & $FF
53-
jmp EXTBootXA
55+
jsr EXTBootXA ; JSR so wrapper restores slot 5 on return
56+
jsr ResetTokenBuffer ; RunNamed returned, program was not found
57+
.error_noprogram
5458

5559
_WSNotSlash:
5660
jsr TKTokeniseLine ; tokenise the line

source/common/generated/kwdconst.inc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,12 @@ KWD_POKEW = $dd; $dd POKEW
157157
KWD_READ = $de; $de READ
158158
KWD_RECT = $df; $df RECT
159159
KWD_REM = $e0; $e0 REM
160-
KWD_SIZE = $e1; $e1 SIZE
161-
KWD_SOLID = $e2; $e2 SOLID
162-
KWD_SOUND = $e3; $e3 SOUND
163-
KWD_SPRITE = $e4; $e4 SPRITE
164-
KWD_TEXT = $e5; $e5 TEXT
165-
KWD_TO = $e6; $e6 TO
166-
KWD_STEP = $e7; $e7 STEP
160+
KWD_SOLID = $e1; $e1 SOLID
161+
KWD_SOUND = $e2; $e2 SOUND
162+
KWD_SPRITE = $e3; $e3 SPRITE
163+
KWD_TEXT = $e4; $e4 TEXT
164+
KWD_TO = $e5; $e5 TO
165+
KWD_STEP = $e6; $e6 STEP
167166
KWD1_ASSEMBLE = $83; $83 ASSEMBLE
168167
KWD1_ASSERT = $84; $84 ASSERT
169168
KWD1_BITMAP = $85; $85 BITMAP

source/common/generated/kwdtext.dat

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,12 @@ KeywordSet0:
100100
.text 4,$1c,"READ" ; $de READ
101101
.text 4,$2e,"RECT" ; $df RECT
102102
.text 3,$e4,"REM" ; $e0 REM
103-
.text 4,$3b,"SIZE" ; $e1 SIZE
104-
.text 5,$7b,"SOLID" ; $e2 SOLID
105-
.text 5,$89,"SOUND" ; $e3 SOUND
106-
.text 6,$d7,"SPRITE" ; $e4 SPRITE
107-
.text 4,$45,"TEXT" ; $e5 TEXT
108-
.text 2,$a3,"TO" ; $e6 TO
109-
.text 4,$3c,"STEP" ; $e7 STEP
103+
.text 5,$7b,"SOLID" ; $e1 SOLID
104+
.text 5,$89,"SOUND" ; $e2 SOUND
105+
.text 6,$d7,"SPRITE" ; $e3 SPRITE
106+
.text 4,$45,"TEXT" ; $e4 TEXT
107+
.text 2,$a3,"TO" ; $e5 TO
108+
.text 4,$3c,"STEP" ; $e6 STEP
110109
.text $FF
111110
KeywordSet1:
112111
.text 0,$65,"" ; $80 !0:EOF

source/common/generated/vectors.dat

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,12 @@ VectorSet0:
164164
.word Command_Read ; $de READ
165165
.word RectangleCommand ; $df RECT
166166
.word RemCommand ; $e0 REM
167-
.word SyntaxError ; $e1 SIZE
168-
.word SyntaxError ; $e2 SOLID
169-
.word SoundCommand ; $e3 SOUND
170-
.word SpriteCommand ; $e4 SPRITE
171-
.word TextCommand ; $e5 TEXT
172-
.word Unused2 ; $e6 TO
173-
.word Unused5 ; $e7 STEP
167+
.word SyntaxError ; $e1 SOLID
168+
.word SoundCommand ; $e2 SOUND
169+
.word SpriteCommand ; $e3 SPRITE
170+
.word TextCommand ; $e4 TEXT
171+
.word Unused2 ; $e5 TO
172+
.word Unused5 ; $e6 STEP
174173
VectorSet1:
175174
.word SyntaxError ; $80 !0:EOF
176175
.word SyntaxError ; $81 !1:SH1

source/scripts/tokens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def get(self):
5555
from plot on off palette sound
5656
poke pokew pokel poked memcopy clear
5757
step~
58-
name size
58+
name
5959
6060
{1} // Set 1
6161
end new list run stop

0 commit comments

Comments
 (0)