M3: programs that bring their own vectors
> load Asm.sbx
> run Keys.asm
wrote Keys.sbx: program 558, data 85, labels 52
> load Keys.sbx
> run
keys, by interrupt. q stops.
ab
the console has been handed back
The machine assembles a program carrying an interrupt handler, the loader
installs its vector, the console interrupts into it, and the shell takes the
vector back at exit. Byte for byte identical to the C assembler's, and
Tests/native.sh now checks a boot image and four loadable programs on every
run.
WHAT IT TOOK:
A declaration and an implementation are the SAME ENTRY. services.asm says
a service is called osPrintString and has number 16; cosmos.asm says
osPrintString is handled by handlePrintString. The name is met twice and
the second time fills in the handler, which is what lets one shared file
serve both the caller and the implementer.
So the first pass declares and the second implements. That is forced: a
handler is an address, and no address is known until every label has been
placed.
Boot in a loadable program fills the entry field rather than being
installed - vector zero is where the whole machine starts, and a program
loaded into a running system has no business saying anything about that.
A boot image is the one thing that does, so there it is installed like any
other, behind a "VEC" marker in the SPBT file.
Device is named by the port, and Device with the five reserved names are
matched without regard to case, the way mnemonics are: they are part of
the language rather than names the programmer chose. Devices have no names
of their own, so they are given one nothing can type.
TWO BUGS, both of a kind worth naming.
The first: "is this a loadable program" was written out as an OR of the two
segment bases in seven places, and the sense wanted is the opposite in most
of them. One of the seven had it backwards and put a version ONE header on a
file carrying vectors, which a loader is right to refuse. It is one flag
now, settled once and tested the same way everywhere.
The second: finding the entry to write a handler into means calling vecFind,
which reads the entry's fields out - including the handler it does not have
yet. An address resolved into VecHandler before the find was overwritten
with zero by the find itself, and the file came out with a vector pointing
at address zero: a slot that looked installed and went nowhere. The
resolved address has a variable of its own now.
Keys.asm and console.asm go on the CosmOS disk, so the whole path can be
watched rather than only tested.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
04424a8917
commit
20989c3439
@@ -673,6 +673,35 @@ clsDigitNo:
|
||||
|
||||
; ---- Odds and ends ----
|
||||
|
||||
; Q is zero if the strings at DP0 and DP1 are the same, ignoring case.
|
||||
;
|
||||
; For the words that are part of the LANGUAGE rather than names somebody chose: Device, and
|
||||
; the vectors the machine already uses. Mnemonics are matched the same way, for the same
|
||||
; reason - nobody should have to remember how the manual capitalised something.
|
||||
sameFolded:
|
||||
LDA.0
|
||||
CALL clsUpper
|
||||
SETD.2 ClsByte
|
||||
LDA.2
|
||||
SETD.2 ClsFoldHold
|
||||
STA.2
|
||||
LDA.1
|
||||
CALL clsUpper
|
||||
SETD.2 ClsByte
|
||||
LDA.2
|
||||
SETD.2 ClsFoldHold
|
||||
LDB.2
|
||||
CCF
|
||||
SUB
|
||||
BNQ sameFoldedDone
|
||||
LDA.0
|
||||
BRA sameFoldedDone ; They ended together, so they matched all the way.
|
||||
INCD.0
|
||||
INCD.1
|
||||
BRI sameFolded
|
||||
sameFoldedDone:
|
||||
RET
|
||||
|
||||
; ClsLength becomes the byte in A. Everything but a string is a small number, and this is
|
||||
; how a small number is written into a sixteen bit field.
|
||||
clsSetLength:
|
||||
@@ -814,6 +843,8 @@ ClsDigitHold:
|
||||
0x00
|
||||
ClsByte:
|
||||
0x00
|
||||
ClsFoldHold:
|
||||
0x00
|
||||
ClsLeft:
|
||||
0x00
|
||||
ClsLeft2:
|
||||
|
||||
Reference in New Issue
Block a user