Programs can now pin specific routines to specific vectors in SplitBit assembly. Added snake game.

This commit is contained in:
Anachronaut
2026-08-17 19:12:42 -04:00
parent 08624925fe
commit 9e3425d34b
18 changed files with 1383 additions and 47 deletions
@@ -0,0 +1,19 @@
; A vector pinned to a number that is not anybody's to give.
;
; 100 is in the range the assembler hands out by itself. A program that pinned one there
; would be claiming a number that the assembler might also give to the next trap somebody
; declared, which is exactly the collision pinning exists to prevent.
#Program
start:
SWI mine
HALT
myHandler:
RETI
#Vectors
Boot start
mine 0d100 myHandler
@@ -0,0 +1,28 @@
; Two vectors pinned to the same number.
;
; This is the mistake pinning makes possible: numbers the assembler hands out cannot
; collide, and numbers a person writes down can. Since the whole point of a pinned number
; is that something outside this program is going to use it, two names sharing one is a
; disagreement that has to be caught here rather than discovered by whatever calls the
; wrong one.
;
; The service names in services.asm sit at 16, 17 and 18, so a program that includes them
; and pins its own trap at one of those is caught by this same check.
#Program
start:
SWI first
HALT
firstHandler:
RETI
secondHandler:
RETI
#Vectors
Boot start
first 0d20 firstHandler
second 0d20 secondHandler
@@ -0,0 +1,78 @@
; Vectors with numbers written down, and vectors numbered by the assembler, in one program.
;
; A software vector number matters only when two separately assembled programs have to
; agree about it. The system's services are the case that exists today: something calls
; osExit without having been assembled alongside whatever implements it, so both sides
; have to mean the same number by that name.
;
; Numbers from 16 to 63 are for exactly that and are never handed out. Everything from 64
; up is handed out in the order it is written, and belongs to one program.
;
; This pins one at each end of the reserved range and leaves a third to the assembler. All
; three are then called by name, which is the only way a program ever refers to one - the
; number is a fact about the machine, not something a program says twice.
;
; Correct output is:
; pinned vectors
; twenty
; sixty three
; automatic
; done
#Include console.asm
#Program
start:
SETD.0 Banner
CALL printString
CALL newLine
SWI atTwenty
SWI atSixtyThree
SWI automatic
SETD.0 DoneText
CALL printString
CALL newLine
HALT
; Each of these says which one it is, so a number going to the wrong place is a wrong word
; rather than a silence.
twentyHandler:
SETD.0 TwentyText
CALL printString
CALL newLine
RETI
sixtyThreeHandler:
SETD.0 SixtyThreeText
CALL printString
CALL newLine
RETI
automaticHandler:
SETD.0 AutomaticText
CALL printString
CALL newLine
RETI
#Data
Banner:
"pinned vectors"
TwentyText:
"twenty"
SixtyThreeText:
"sixty three"
AutomaticText:
"automatic"
DoneText:
"done"
#Vectors
Boot start
atTwenty 0d20 twentyHandler
atSixtyThree 0d63 sixtyThreeHandler
automatic automaticHandler