diff --git a/Programs/CosmOS/Apps/Grid.asm b/Programs/CosmOS/Apps/Grid.asm index a1e8a52..f04e0db 100644 --- a/Programs/CosmOS/Apps/Grid.asm +++ b/Programs/CosmOS/Apps/Grid.asm @@ -30,7 +30,14 @@ start: ; ; The CPU cannot touch it. It belongs to the device, and the only way in is to give it a ; bank number and go through the memory controller - the same as the disk's buffer. - INIA 0d3 + ; + ; FOUR, BECAUSE THREE IS THE DISK'S. Bank numbers are one namespace for the whole machine + ; and nothing hands them out: 0 is Program Memory, 1 is Data, 2 is the bank table, and + ; CosmOS gives 3 to the disk's buffer when it mounts. This asked for 3, which does not + ; fail - it succeeds, and the disk's buffer quietly becomes the screen. Every read the + ; filesystem made after that came out of video memory, so the shell found an empty disk + ; and could not start anything by name. Nothing said a word. + INIA 0d4 OUTA 0xE3 ; DestBank: the number it will answer to. INIA 0x30 OUTA 0xE2 ; SourceLow: the port of the device that owns it. @@ -123,7 +130,7 @@ finished: ; grid underneath its own output. OUTA 0x34 ; A is still nought, from the three above. - INIA 0d3 + INIA 0d4 OUTA 0xE3 INIA 0x40 OUTA 0xE4 @@ -137,6 +144,15 @@ finished: INIA 0x02 OUTA 0xE8 ; Fill. + ; ---- And the cursor back to the top ---- + ; + ; The Fill above empties the map and says nothing to the console about it, so the shell + ; carried on writing from wherever the cursor had been left standing when this program + ; started - part way down a screen that no longer has anything on it. Clearing is what + ; puts a cursor home, and it costs one write. + INIA 0x01 + OUTA 0x05 + ; ---- And the colours it woke up with ---- ; ; Only the first pair, and that is worth being honest about. The console's own scheme is @@ -154,7 +170,7 @@ finished: ; THE REAL ANSWER IS A COMMAND TO THE SCREEN saying "give me back what you woke up with", ; the same way the console has one for clearing. There is not one, and this program is the ; first thing that ever wanted it. - INIA 0d3 + INIA 0d4 OUTA 0xE3 INIA 0xFC OUTA 0xE4 @@ -206,7 +222,7 @@ putTile: INCD.1 LDA.1 OUTA 0xE2 - INIA 0d3 + INIA 0d4 OUTA 0xE3 INIA 0x32 OUTA 0xE4 @@ -239,7 +255,7 @@ putTile: ; writes with no arithmetic in it at all. The colours that change do so by adding sixteen to ; a running value, which is the same reason. putPalette: - INIA 0d3 + INIA 0d4 OUTA 0xE3 INIA 0xFC OUTA 0xE4 @@ -330,7 +346,7 @@ putMap: STA.0 everyRow: - INIA 0d3 + INIA 0d4 OUTA 0xE3 SETD.0 MapRow LDA.0 diff --git a/Programs/CosmOS/README.md b/Programs/CosmOS/README.md index c053f1f..4ee1d09 100644 --- a/Programs/CosmOS/README.md +++ b/Programs/CosmOS/README.md @@ -797,6 +797,31 @@ An application may also include its own libraries or access hardware ports direc The services are an interface offered by the system, not the only way software is allowed to use the computer. +### Bank Numbers Are One Namespace: + +A program that wants a device's memory registers it as a bank, and **bank numbers belong to +the whole machine**. Nothing hands them out and nothing refuses a number that is already +spoken for - registering one that is taken does not fail, it succeeds, and whatever held it +before quietly answers to nothing. + +| Bank | Whose | +| --- | --- | +| 0 | Program Memory. The machine's. | +| 1 | Data Memory. The machine's. | +| 2 | The bank table. The machine's. | +| 3 | The disk's buffer, given at mount by `sbfsMount`. CosmOS needs it for as long as it is running. | +| 4 and up | Free for a program to use. | + +`Grid` learned this the hard way and is the reason the table is here. It asked for 3, took the +disk's buffer, and every read the filesystem made afterwards came out of video memory - so the +shell found an empty disk and could not start anything by name, several commands after the +program that did it had exited. Nothing said a word, because from the controller's point of +view nothing went wrong. + +**A program returns a bank by giving it back**, which today means knowing what was there +before. There is no service that hands out a free number, and if this becomes a common thing +for programs to want then that is what should exist rather than a longer table. + ## What A Program May Ask The System For: A loaded program is on its own hardware and can do anything the machine can do - it is a fence, not a wall. But the things it usually wants are things the system is already doing, and asking is both shorter and the only way to reach code that was assembled separately. `CALL` needs a label, and a label has to be in the same assembly; `SWI` needs only a number both sides agree on. diff --git a/SplitBit Test Manual.md b/SplitBit Test Manual.md index fea2842..ad2d5b6 100644 --- a/SplitBit Test Manual.md +++ b/SplitBit Test Manual.md @@ -79,7 +79,7 @@ from `make`, not from here. ### 1. Recorded output `Tests/run.sh` assembles each program named in `Tests/manifest`, runs it, and compares -everything it printed against a file in `Tests/expected`. 177 tests, of which 115 run, 35 +everything it printed against a file in `Tests/expected`. 178 tests, of which 116 run, 35 only assemble, 16 are expected to fail to assemble, and 11 boot from ROM with no image given at all. diff --git a/Tests/expected/cosmosGrid.out b/Tests/expected/cosmosGrid.out new file mode 100644 index 0000000..ec1328e --- /dev/null +++ b/Tests/expected/cosmosGrid.out @@ -0,0 +1,27 @@ +CosmOS +> it says: before Grid +finished +> finished +> > it says: after Grid +finished +> greet.sbx 211 +hello.sbx 53 +Life.sbx 1396 +Snake.sbx 2164 +Keys.sbx 664 +Say.sbx 156 +Break.sbx 149 +Grid.sbx 543 +notes.txt 21 +hi.script 121 +bad.script 45 +plain.script 24 +cross.script 280 +nonl.script 38 +outer.script 376 +inner.script 44 +loop.script 35 +17 files +> halted +Execution halted. +[exit 0] diff --git a/Tests/expected/cosmosRun.out b/Tests/expected/cosmosRun.out index a8d88f2..f402531 100644 --- a/Tests/expected/cosmosRun.out +++ b/Tests/expected/cosmosRun.out @@ -7,7 +7,7 @@ Snake.sbx 2164 Keys.sbx 664 Say.sbx 156 Break.sbx 149 -Grid.sbx 539 +Grid.sbx 543 notes.txt 21 hi.script 121 bad.script 45 diff --git a/Tests/expected/cosmosSlowDisk.out b/Tests/expected/cosmosSlowDisk.out index d46b048..ebbec3a 100644 --- a/Tests/expected/cosmosSlowDisk.out +++ b/Tests/expected/cosmosSlowDisk.out @@ -6,7 +6,7 @@ Snake.sbx 2164 Keys.sbx 664 Say.sbx 156 Break.sbx 149 -Grid.sbx 539 +Grid.sbx 543 notes.txt 21 hi.script 121 bad.script 45 diff --git a/Tests/input/cosmosGrid.in b/Tests/input/cosmosGrid.in new file mode 100644 index 0000000..2a3c357 --- /dev/null +++ b/Tests/input/cosmosGrid.in @@ -0,0 +1,6 @@ +Say before Grid +Grid +q +Say after Grid +dir +exit diff --git a/Tests/manifest b/Tests/manifest index 1270056..e17e0b6 100644 --- a/Tests/manifest +++ b/Tests/manifest @@ -791,6 +791,17 @@ cosmosStartup | CosmOS/Source/cosmos.asm | run | cosmosSta # Present, and not a script. A missing one is ordinary and says nothing; one somebody meant # to run and got wrong is worth a word. cosmosStartupBad | CosmOS/Source/cosmos.asm | run | cosmosStartup.in | 200000000 | disks/startupbad.img +# ---- A program that takes the screen, and gives the disk back ---- +# +# Grid registers video memory as a bank, and bank numbers are one namespace for the whole +# machine with nothing handing them out. It asked for 3, which is the one CosmOS gives the +# disk's buffer at mount - and that does not fail, it SUCCEEDS: every read the filesystem +# made afterwards came out of video memory. The shell found an empty disk and could not +# start anything by name, and nothing said a word. +# +# So this runs a program by name, then Grid, then the same program again. The second one is +# the check. dir at the end says the disk is still there to be read. +cosmosGrid | CosmOS/Source/cosmos.asm | run | cosmosGrid.in | 60000000 | disks/cosmos.img printDecimalTest | testPrograms/printDecimalTest.asm | xfail | - | - printDigitTest | testPrograms/printDigitTest.asm | xfail | - | - printHexTest | testPrograms/printHexTest.asm | xfail | - | -