Browse Source

zasm now bootstraps itself without scas!

pull/10/head
Virgil Dupras 5 years ago
parent
commit
fa3b86a5c1
5 changed files with 27 additions and 11 deletions
  1. +14
    -10
      tools/emul/Makefile
  2. +12
    -0
      tools/emul/README.md
  3. +1
    -1
      tools/emul/zasm/glue.asm
  4. BIN
      tools/emul/zasm/kernel.bin
  5. BIN
      tools/emul/zasm/zasm.bin

+ 14
- 10
tools/emul/Makefile View File

@@ -1,27 +1,26 @@
TARGETS = shell/shell zasm/zasm runbin/runbin
KERNEL_HEADERS = shell/kernel.h zasm/kernel.h
USER_HEADERS = zasm/user.h
CFSPACK = ../cfspack/cfspack
KERNEL = ../../kernel
APPS = ../../apps
ZASMBIN = zasm/zasm

.PHONY: all
all: $(TARGETS)

shell/kernel.h: shell/shell_.asm
zasm/kernel.h: zasm/glue.asm
$(KERNEL_HEADERS):
scas -o - -I $(KERNEL) $< | ./bin2c.sh KERNEL | tee $@ > /dev/null

zasm/user.h: $(APPS)/zasm/glue.asm
$(USER_HEADERS):
scas -o - -I $(APPS) $< | ./bin2c.sh USERSPACE | tee $@ > /dev/null
zasm/kernel.h: zasm/kernel.bin
./bin2c.sh KERNEL < $< | tee $@ > /dev/null

zasm/user.h: zasm/zasm.bin
./bin2c.sh USERSPACE < $< | tee $@ > /dev/null

zasm/includes.cfs: $(CFSPACK)
rm -rf zasm/includes
cp -r $(KERNEL) zasm/includes
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' {} \;
cp user.h zasm/includes
$(CFSPACK) zasm/includes > $@
@@ -31,7 +30,7 @@ zasm/includes.h: zasm/includes.cfs
./bin2c.sh FSDEV < $< | tee $@ > /dev/null
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
$(TARGETS):
cc $< libz80/libz80.o -o $@
@@ -43,6 +42,11 @@ libz80/libz80.o: libz80/z80.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
clean:
rm -f $(TARGETS) $(KERNEL_HEADERS) $(USER_HEADERS) zasm/includes.*
rm -f $(TARGETS) zasm/{kernel,user}.h shell/kernel.h zasm/includes.*

+ 12
- 0
tools/emul/README.md 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
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

First, make sure that the `libz80` git submodule is checked out. If not, run


+ 1
- 1
tools/emul/zasm/glue.asm View File

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

init:
di


BIN
tools/emul/zasm/kernel.bin View File


BIN
tools/emul/zasm/zasm.bin View File


Loading…
Cancel
Save