The memory map gave CosmOS 0x0000 through 0x1FFF of Program Memory and applications 0x2000 and above. CosmOS is 8141 bytes at the previous commit, which is fifty one bytes short of the line, and the next thing added to it went over. GOING OVER DOES NOT FAIL WHERE IT HAPPENS. Nothing enforces the division: an application says where it goes with #Base and the loader puts it there, so a CosmOS that has grown past 0x1FFF simply has the next program loaded written over the end of it. What breaks is whichever part of the shell that program happened to cover, at whatever later moment somebody uses it. It turned up here as the monitor's assemble command answering "I do not know" to valid instructions, several commands into a session, on a machine that had booted perfectly well. Both halves are doubled: applications now start at 0x4000 in Program Memory and 0x2000 in Data Memory. That is 16K of code and 8K of data for the system, against the 8775 and 2948 it uses today. Both were on the same trajectory, and moving them together means the twenty files that say #Base are edited once rather than twice. The standalone loader's loadable.asm keeps its old base: it belongs to the loader CosmOS grew out of, not to CosmOS, and its addresses answer to a different program. The unbased-segment diagnostic keeps its old base too - it exists to produce an error message that names the address, and the message is what is recorded. Tests/docs.sh now reads the two limits out of the table in the README and measures both segments against them. It reads them rather than being told them because the table is the specification, and this is the second time in this project that the thing nobody checked is the thing that rotted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
141 lines
1.9 KiB
NASM
141 lines
1.9 KiB
NASM
; A Fibonacci number generating program that uses four bytes to store the value.
|
|
|
|
#Include services.asm
|
|
|
|
#Program
|
|
|
|
#Base 0x4000
|
|
|
|
start:
|
|
; Swap ValueB and ValueA.
|
|
; First, store ValueA on the stack.
|
|
SETD ValueA
|
|
LDA
|
|
PSHA
|
|
INCD
|
|
LDA
|
|
PSHA
|
|
INCD
|
|
LDA
|
|
PSHA
|
|
INCD
|
|
LDA
|
|
PSHA
|
|
; Next, store ValueB on the stack.
|
|
SETD ValueB
|
|
LDA
|
|
PSHA
|
|
INCD
|
|
LDA
|
|
PSHA
|
|
INCD
|
|
LDA
|
|
PSHA
|
|
INCD
|
|
LDA
|
|
PSHA
|
|
; Then pop ValueB into ValueA.
|
|
SETD ValueA
|
|
INCD INCD INCD
|
|
POPA
|
|
STA
|
|
DECD
|
|
POPA
|
|
STA
|
|
DECD
|
|
POPA
|
|
STA
|
|
DECD
|
|
POPA
|
|
STA
|
|
; Then pop ValueA into ValueB.
|
|
SETD ValueB
|
|
INCD INCD INCD
|
|
POPA
|
|
STA
|
|
DECD
|
|
POPA
|
|
STA
|
|
DECD
|
|
POPA
|
|
STA
|
|
DECD
|
|
POPA
|
|
STA
|
|
; Print ValueA.
|
|
SETD ValueA
|
|
INCD INCD INCD
|
|
LDA
|
|
CALL printByteHex
|
|
DECD
|
|
LDA
|
|
CALL printByteHex
|
|
DECD
|
|
LDA
|
|
CALL printByteHex
|
|
DECD
|
|
LDA
|
|
CALL printByteHex
|
|
CALL blankSpace
|
|
; Now add ValueA and ValueB, and store the result in ValueA.
|
|
; Add the lowest bytes of ValueA and ValueB.
|
|
SETD ValueB
|
|
LDB
|
|
SETD ValueA
|
|
LDA
|
|
ADD
|
|
; Store it in ValueA's lowest byte.
|
|
STQ
|
|
; Add the second lowest bytes of ValueA and ValueB.
|
|
SETD ValueB
|
|
INCD
|
|
LDB
|
|
SETD ValueA
|
|
INCD
|
|
LDA
|
|
ADD
|
|
; Store it in ValueA's second lowest byte.
|
|
STQ
|
|
; Add the second highest bytes of ValueA and ValueB.
|
|
SETD ValueB
|
|
INCD INCD
|
|
LDB
|
|
SETD ValueA
|
|
INCD INCD
|
|
LDA
|
|
ADD
|
|
; Store it in ValueA's third lowest byte.
|
|
STQ
|
|
; Add the highest bytes of ValueA and ValueB.
|
|
SETD ValueB
|
|
INCD INCD INCD
|
|
LDB
|
|
SETD ValueA
|
|
INCD INCD INCD
|
|
LDA
|
|
ADD
|
|
; If this addition overflows, we're done.
|
|
BRC end
|
|
; Otherwise, store the result in ValueA's highest byte.
|
|
STQ
|
|
; And branch back to the beginning of the loop.
|
|
BRI start
|
|
end:
|
|
CALL lineFeed
|
|
;HALT
|
|
SWI osExit
|
|
|
|
#Data
|
|
|
|
#Base 0x2000
|
|
|
|
ValueA:
|
|
; Lowest byte ... Highest byte.
|
|
0x01 0x00 0x00 0x00
|
|
|
|
ValueB:
|
|
; Lowest byte ... Highest byte.
|
|
0x00 0x00 0x00 0x00
|
|
|
|
#Include print.asm
|