Put the assembler and some source on the CosmOS disk

'make run-cosmos' now boots a machine with Asm.sbx on the disk and two
source files to point it at, so the thing can be watched working rather
than only tested:

    > load Asm.sbx
    > run hello.asm
    wrote hello.bin: program 17, data 14, labels 2
    > run strings.asm
    wrote strings.bin: program 62, data 88, labels 4

Both come out byte for byte identical to the C assembler's, and both run.
hello.asm and testPrograms/stringKeyword.asm are the two single-file
programs with no #Include, which is what the native assembler handles so
far; strings.asm is the second because it has a subroutine and a label
used before it is defined, so it exercises a forward reference that
hello.asm does not.

The assembler builds from its own directory rather than from Apps/,
because it is not one file. Its pieces are found beside it without being
told, since an include is looked for next to the file that asked for it
before anywhere else; only services.asm needs the include path.

ALSO A CORRECTION. Asm.asm's header, its usage message and the Assembler
Manual all said 'run Asm.sbx hello.asm'. That is the convention we talked
about wanting later, not the one this shell has: load and run are separate
commands, so the whole rest of the run line is the argument and that form
asks for a file called "Asm.sbx hello.asm". All three now say load first.

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-20 22:20:45 -04:00
co-authored by Claude Opus 5
parent dcb331c151
commit affe9d09ea
3 changed files with 28 additions and 5 deletions
+19 -2
View File
@@ -69,15 +69,32 @@ $(BUILD)/CosmOS/Apps/%.sbx: CosmOS/Apps/%.asm
@mkdir -p $(@D)
$(ASM) $(INCLUDES) -M $(@:.sbx=.d) -o $@ $<
cosmos: $(COSMOS) $(APPS)
# The assembler that runs on the machine. It is not in Apps/ because it is not one file:
# it has a directory of its own, the way the C assembler does. Its own pieces are found
# beside it without being told, since an include is looked for next to the file that asked
# for it before anywhere else; only services.asm needs the include path.
NATIVE_ASM = $(BUILD)/CosmOS/Assembler/Asm.sbx
DEPENDENCIES += $(NATIVE_ASM:.sbx=.d)
$(NATIVE_ASM): CosmOS/Assembler/Asm.asm
@mkdir -p $(@D)
$(ASM) $(INCLUDES) -M $(@:.sbx=.d) -o $@ $<
cosmos: $(COSMOS) $(APPS) $(NATIVE_ASM)
# Made from scratch every time, so that what is on it is what is in Apps/ now and not
# also whatever used to be.
$(COSMOS_DISK): $(APPS)
$(COSMOS_DISK): $(APPS) $(NATIVE_ASM) hello.asm testPrograms/stringKeyword.asm
@mkdir -p $(@D)
rm -f $@
$(DISKTOOL) format $@ 2048 4
@for app in $(APPS); do $(DISKTOOL) put $@ $$app; done
$(DISKTOOL) put $@ $(NATIVE_ASM)
@# SOURCE goes on as well, because an assembler with nothing to assemble is a
@# demonstration of nothing. Both of these are single files with no #Include, which
@# is what the native assembler handles so far.
$(DISKTOOL) put $@ hello.asm
$(DISKTOOL) put $@ testPrograms/stringKeyword.asm strings.asm
# The system as well as the disk. Building only the image leaves whatever cosmos.bin was
# there before, or none at all, and then the disk is booted with a system that does not