Break shows registers it chose, not ones it inherited

Break left DP1 and DP2 alone, so what a stop printed for them was whatever the
shell happened to have left there - which is a CosmOS address, which moves
whenever CosmOS is touched at all. The recorded output had to be taken again
four times in one day's work, every time for a value that is not this program's
and that nothing should ever depend on.

It sets all three of the pointers it owns now, rotated between the two stops so
that every one of them visibly changes, the way A and B already did. DP3 stays
as the system left it: it is where the program was entered, which is the one
thing worth seeing here that this program did not choose, and it is steady
because it is this program's own base.

A demonstration of what the registers were should show registers somebody
chose. Then every line of the record is being asserted rather than merely
observed, and a reader can tell which is which.

Checked both ways: sixty four bytes added to CosmOS's data no longer moves it,
and reading the frame at the wrong offset still fails it.

cosmosRun and cosmosMonitor move because Break is sixteen bytes longer and both
of them list the disk it sits on.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-08-25 17:13:49 -04:00
co-authored by Claude Opus 5
parent fb7b224bbb
commit 00d896e3e7
5 changed files with 33 additions and 7 deletions
+21
View File
@@ -17,6 +17,23 @@
; Correct output is two stops. A and B differ between them, the addresses differ, and the
; Stack Pointer differs too, because the second one is inside a subroutine and a call has
; put ten bytes down by then.
;
; EVERY POINTER IS SET BEFORE EACH STOP, and the three this program owns are rotated
; between the two so that all of them visibly change.
;
; This program used to leave DP1 and DP2 alone, and what a stop then showed for them was
; whatever the shell happened to have left there. That is a real thing about the machine -
; a program is handed the pointers as it finds them - but it is not this program's to
; demonstrate, and it made what this program prints depend on where CosmOS's code happens
; to sit. The recorded output had to be taken again four times in one day's work, every
; time for a value nothing should ever depend on.
;
; A demonstration of what the registers were should show registers somebody chose. Then
; every line of it is being asserted rather than merely observed.
;
; DP3 is deliberately still the system's. It is where the program was entered, which is the
; one thing here worth seeing that this program did not choose, and it is steady because it
; is this program's own base.
#Include services.asm
@@ -31,6 +48,8 @@ start:
INIA 0d17
INIB 0d34
SETD.0 Marker
SETD.1 Banner
SETD.2 DoneText
SWI osBreak
; The second stop is inside a subroutine, so that the Stack Pointer is visibly not where
@@ -45,6 +64,8 @@ deeper:
INIA 0d68
INIB 0d85
SETD.0 Banner
SETD.1 DoneText
SETD.2 Marker
SWI osBreak
RET
+4 -4
View File
@@ -1,13 +1,13 @@
CosmOS
> loaded, starting at 4000
> two stops, and what the registers were at each
break at 400E
break at 4016
A 11 B 22 Q 00 status 00
DP0 2030 DP1 09F7 DP2 0000 DP3 4000 SP FFFF
DP0 2030 DP1 2000 DP2 2037 DP3 4000 SP FFFF
press a key
break at 4023
break at 4033
A 44 B 55 Q 00 status 00
DP0 2000 DP1 09F7 DP2 0000 DP3 4000 SP FFF5
DP0 2000 DP1 2037 DP2 2030 DP3 4000 SP FFF5
press a key
carried on to the end
finished
+1 -1
View File
@@ -66,7 +66,7 @@ Life.sbx 1411
Snake.sbx 2175
Keys.sbx 663
Say.sbx 155
Break.sbx 132
Break.sbx 148
notes.txt 21
8 files
> halted
+1 -1
View File
@@ -6,7 +6,7 @@ Life.sbx 1411
Snake.sbx 2175
Keys.sbx 663
Say.sbx 155
Break.sbx 132
Break.sbx 148
notes.txt 21
8 files
> load what?
+6 -1
View File
@@ -285,7 +285,12 @@ cosmosSay | CosmOS/Source/cosmos.asm | run | cosmosSay
# design and one that overwrites an instruction, since an overwritten instruction has to be
# put back to continue and putting it back is the same act as disarming the breakpoint.
# Every value shown comes out of the interrupt frame rather than the registers, because by
# the time the handler runs the registers are the handler's.
# the time the handler runs the registers are the handler's. Break sets all three of the
# pointers it owns and rotates them between the two stops, so every value recorded here is
# one something chose - it used to leave two of them holding whatever the shell had left,
# which tied this record to where CosmOS's code sits and made it churn on changes that had
# nothing to do with breakpoints. DP3 is left as the system set it, being where the program
# was entered.
cosmosBreak | CosmOS/Source/cosmos.asm | run | cosmosBreak.in | - | disks/cosmos.img
# The editor, which is the first program on this machine that makes a file a person typed:
# every byte on every other image here was put there by the host tool. It is run twice in