1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 22:58:06 +11:00

zasm now bootstraps itself without scas!

This commit is contained in:
Virgil Dupras 2019-05-19 15:03:34 -04:00
parent acddb045a5
commit fa3b86a5c1
5 changed files with 27 additions and 11 deletions

View File

@ -1,27 +1,26 @@
TARGETS = shell/shell zasm/zasm runbin/runbin TARGETS = shell/shell zasm/zasm runbin/runbin
KERNEL_HEADERS = shell/kernel.h zasm/kernel.h
USER_HEADERS = zasm/user.h
CFSPACK = ../cfspack/cfspack CFSPACK = ../cfspack/cfspack
KERNEL = ../../kernel KERNEL = ../../kernel
APPS = ../../apps APPS = ../../apps
ZASMBIN = zasm/zasm
.PHONY: all .PHONY: all
all: $(TARGETS) all: $(TARGETS)
shell/kernel.h: shell/shell_.asm shell/kernel.h: shell/shell_.asm
zasm/kernel.h: zasm/glue.asm
$(KERNEL_HEADERS):
scas -o - -I $(KERNEL) $< | ./bin2c.sh KERNEL | tee $@ > /dev/null scas -o - -I $(KERNEL) $< | ./bin2c.sh KERNEL | tee $@ > /dev/null
zasm/user.h: $(APPS)/zasm/glue.asm zasm/kernel.h: zasm/kernel.bin
$(USER_HEADERS): ./bin2c.sh KERNEL < $< | tee $@ > /dev/null
scas -o - -I $(APPS) $< | ./bin2c.sh USERSPACE | tee $@ > /dev/null
zasm/user.h: zasm/zasm.bin
./bin2c.sh USERSPACE < $< | tee $@ > /dev/null
zasm/includes.cfs: $(CFSPACK) zasm/includes.cfs: $(CFSPACK)
rm -rf zasm/includes rm -rf zasm/includes
cp -r $(KERNEL) zasm/includes cp -r $(KERNEL) zasm/includes
cp -r $(APPS)/zasm zasm/includes/zasm cp -r $(APPS)/zasm zasm/includes/zasm
find zasm/includes -name *.md -o -name *.example -delete find zasm/includes -name *.md -o -name *.example -o -name glue.asm -delete
find zasm/includes -type f -exec sed -i -e 's/;.*//g' {} \; find zasm/includes -type f -exec sed -i -e 's/;.*//g' {} \;
cp user.h zasm/includes cp user.h zasm/includes
$(CFSPACK) zasm/includes > $@ $(CFSPACK) zasm/includes > $@
@ -31,7 +30,7 @@ zasm/includes.h: zasm/includes.cfs
./bin2c.sh FSDEV < $< | tee $@ > /dev/null ./bin2c.sh FSDEV < $< | tee $@ > /dev/null
shell/shell: shell/shell.c libz80/libz80.o shell/kernel.h $(CFSPACK) shell/shell: shell/shell.c libz80/libz80.o shell/kernel.h $(CFSPACK)
zasm/zasm: zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/user.h zasm/includes.h $(ZASMBIN): zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/user.h zasm/includes.h
runbin/runbin: runbin/runbin.c libz80/libz80.o runbin/runbin: runbin/runbin.c libz80/libz80.o
$(TARGETS): $(TARGETS):
cc $< libz80/libz80.o -o $@ cc $< libz80/libz80.o -o $@
@ -43,6 +42,11 @@ libz80/libz80.o: libz80/z80.c
$(CFSPACK): $(CFSPACK):
make -C ../cfspack make -C ../cfspack
.PHONY: updatebootstrap
updatebootstrap: $(ZASMBIN)
$(ZASMBIN) < zasm/glue.asm > zasm/kernel.bin
$(ZASMBIN) < $(APPS)/zasm/glue.asm > zasm/zasm.bin
.PHONY: clean .PHONY: clean
clean: clean:
rm -f $(TARGETS) $(KERNEL_HEADERS) $(USER_HEADERS) zasm/includes.* rm -f $(TARGETS) zasm/{kernel,user}.h shell/kernel.h zasm/includes.*

View File

@ -13,6 +13,18 @@ We don't try to emulate real hardware to ease the development of device drivers
because so far, I don't see the advantage of emulation versus running code on because so far, I don't see the advantage of emulation versus running code on
the real thing. the real thing.
## Bootstrapped binary
The file `zasm/zasm.bin` is a compiled binary for `apps/zasm/glue.asm`. It is
used to bootstrap the assembling process so that no assembler other than zasm
is required to build Collapse OS.
This binary is fed to libz80 to produce the `zasm/zasm` "modern" binary and
once you have that, you can recreate `zasm/zasm.bin`.
This is why it's included as a binary in the repo, but yes, it's redundant with
the source code.
## Usage ## Usage
First, make sure that the `libz80` git submodule is checked out. If not, run First, make sure that the `libz80` git submodule is checked out. If not, run

View File

@ -1,5 +1,6 @@
; Glue code for the emulated environment ; Glue code for the emulated environment
.equ RAMSTART 0x4000 .equ RAMSTART 0x4000
.equ USER_CODE 0x4800
.equ STDIO_PORT 0x00 .equ STDIO_PORT 0x00
.equ STDIN_SEEK 0x01 .equ STDIN_SEEK 0x01
.equ FS_DATA_PORT 0x02 .equ FS_DATA_PORT 0x02
@ -39,7 +40,6 @@ jp fsTell
.equ FS_RAMSTART BLOCKDEV_RAMEND .equ FS_RAMSTART BLOCKDEV_RAMEND
.equ FS_HANDLE_COUNT 0 .equ FS_HANDLE_COUNT 0
#include "fs.asm" #include "fs.asm"
#include "user.h"
init: init:
di di

BIN
tools/emul/zasm/kernel.bin Normal file

Binary file not shown.

BIN
tools/emul/zasm/zasm.bin Normal file

Binary file not shown.