diff --git a/Programs/CosmOS/Assembler/Asm.asm b/Programs/CosmOS/Assembler/Asm.asm index 39fdfdf..69f0a2d 100644 --- a/Programs/CosmOS/Assembler/Asm.asm +++ b/Programs/CosmOS/Assembler/Asm.asm @@ -1,6 +1,10 @@ ; The SplitBit assembler, running on SplitBit. ; -; run Asm.sbx hello.asm +; > load Asm.sbx +; > run hello.asm +; +; Loading and running are separate commands in this shell, so the file to assemble is the +; argument to run rather than a second name after the program's. ; ; Reads assembly source off the disk and writes a binary back to it, with no host involved ; anywhere. The output has to be byte for byte what the C assembler produces from the same @@ -829,7 +833,7 @@ WordData: "#Data" UsageText: -"say which file: run Asm.sbx hello.asm +"say which file to assemble, as in: run hello.asm " NoSourceText: "no such file: " diff --git a/Programs/makefile b/Programs/makefile index fd01eec..06323c7 100644 --- a/Programs/makefile +++ b/Programs/makefile @@ -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 diff --git a/SplitBit Assembler Manual.md b/SplitBit Assembler Manual.md index 20663d0..034dacb 100644 --- a/SplitBit Assembler Manual.md +++ b/SplitBit Assembler Manual.md @@ -485,10 +485,12 @@ There are two assemblers now. This manual has been describing the one that runs ``` > load Asm.sbx -> run Asm.sbx hello.asm +> run hello.asm wrote hello.bin: program 17, data 14, labels 2 ``` +Loading and running are separate commands in CosmOS, so the source file is the argument to `run`. + **Its output must be byte for byte what the host assembler produces from the same source**, and `Tests/native.sh` checks exactly that: it assembles `Programs/hello.asm` both ways and compares the files, then runs the one the machine built. This is the discipline SplitDisk and `sbfs.asm` already work under — two implementations of one written specification, each one checking the other. "It ran" is not good enough for an assembler, because a binary with a label one byte out runs right up until it jumps into the middle of an instruction. ### How It Differs Inside: