... instead of embedding it in the binary itself. Additionally, add a "zasm.sh" wrapper to faciliate zasm calls on a linux machine.pull/10/head
@@ -1,5 +1,5 @@ | |||||
TARGET = os.bin | TARGET = os.bin | ||||
ZASM = ../../tools/emul/zasm/zasm | |||||
ZASM = ../../tools/zasm.sh | |||||
.PHONY: all | .PHONY: all | ||||
all: $(TARGET) | all: $(TARGET) | ||||
@@ -11,6 +11,7 @@ jp init | |||||
.fill 0x38-$ | .fill 0x38-$ | ||||
jp aciaInt | jp aciaInt | ||||
#include "err.h" | |||||
#include "core.asm" | #include "core.asm" | ||||
#include "parse.asm" | #include "parse.asm" | ||||
.equ ACIA_RAMSTART RAMSTART | .equ ACIA_RAMSTART RAMSTART | ||||
@@ -1,6 +1,6 @@ | |||||
TARGETS = os.bin cfsin/helo | TARGETS = os.bin cfsin/helo | ||||
TOOLS = ../../../tools | TOOLS = ../../../tools | ||||
ZASM = $(TOOLS)/emul/zasm/zasm | |||||
ZASM = $(TOOLS)/zasm.sh | |||||
CFSPACK = $(TOOLS)/cfspack/cfspack | CFSPACK = $(TOOLS)/cfspack/cfspack | ||||
.PHONY: all | .PHONY: all | ||||
@@ -1,7 +1,5 @@ | |||||
# Accessing a MicroSD card | # Accessing a MicroSD card | ||||
**Status: work in progress.** | |||||
SD cards are great because they are accessible directly. No supporting IC is | SD cards are great because they are accessible directly. No supporting IC is | ||||
necessary. The easiest way to access them is through the SPI protocol. | necessary. The easiest way to access them is through the SPI protocol. | ||||
@@ -20,6 +20,7 @@ jp sdcSendRecv | |||||
.fill 0x38-$ | .fill 0x38-$ | ||||
jp aciaInt | jp aciaInt | ||||
#include "err.h" | |||||
#include "core.asm" | #include "core.asm" | ||||
#include "parse.asm" | #include "parse.asm" | ||||
.equ ACIA_RAMSTART RAMSTART | .equ ACIA_RAMSTART RAMSTART | ||||
@@ -3,12 +3,13 @@ CFSPACK = ../cfspack/cfspack | |||||
KERNEL = ../../kernel | KERNEL = ../../kernel | ||||
APPS = ../../apps | APPS = ../../apps | ||||
ZASMBIN = zasm/zasm | ZASMBIN = zasm/zasm | ||||
INCCFS = zasm/includes.cfs | |||||
.PHONY: all | .PHONY: all | ||||
all: $(TARGETS) | all: $(TARGETS) | ||||
shell/kernel.h: shell/shell_.asm $(ZASMBIN) | |||||
$(ZASMBIN) < $< | ./bin2c.sh KERNEL | tee $@ > /dev/null | |||||
shell/kernel.h: shell/shell_.asm $(ZASMBIN) $(INCCFS) | |||||
$(ZASMBIN) $(INCCFS) < $< | ./bin2c.sh KERNEL | tee $@ > /dev/null | |||||
zasm/kernel.h: zasm/kernel.bin | zasm/kernel.h: zasm/kernel.bin | ||||
./bin2c.sh KERNEL < $< | tee $@ > /dev/null | ./bin2c.sh KERNEL < $< | tee $@ > /dev/null | ||||
@@ -16,7 +17,7 @@ zasm/kernel.h: zasm/kernel.bin | |||||
zasm/user.h: zasm/zasm.bin | zasm/user.h: zasm/zasm.bin | ||||
./bin2c.sh USERSPACE < $< | tee $@ > /dev/null | ./bin2c.sh USERSPACE < $< | tee $@ > /dev/null | ||||
zasm/includes.cfs: $(CFSPACK) | |||||
$(INCCFS): $(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 | ||||
@@ -26,11 +27,8 @@ zasm/includes.cfs: $(CFSPACK) | |||||
$(CFSPACK) zasm/includes > $@ | $(CFSPACK) zasm/includes > $@ | ||||
rm -rf zasm/includes | rm -rf zasm/includes | ||||
zasm/includes.h: zasm/includes.cfs | |||||
./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) | ||||
$(ZASMBIN): 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 | |||||
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,9 +41,9 @@ $(CFSPACK): | |||||
make -C ../cfspack | make -C ../cfspack | ||||
.PHONY: updatebootstrap | .PHONY: updatebootstrap | ||||
updatebootstrap: $(ZASMBIN) | |||||
$(ZASMBIN) < zasm/glue.asm > zasm/kernel.bin | |||||
$(ZASMBIN) < $(APPS)/zasm/glue.asm > zasm/zasm.bin | |||||
updatebootstrap: $(ZASMBIN) $(INCCFS) | |||||
$(ZASMBIN) $(INCCFS) < zasm/glue.asm > zasm/kernel.bin | |||||
$(ZASMBIN) $(INCCFS) < $(APPS)/zasm/glue.asm > zasm/zasm.bin | |||||
# Sometimes, when developing zasm, stuff get messed up and it's hard to unmess | # Sometimes, when developing zasm, stuff get messed up and it's hard to unmess | ||||
# because zasm's brake-up ends up in its bootstrap bins. Sure, we can revert | # because zasm's brake-up ends up in its bootstrap bins. Sure, we can revert | ||||
@@ -3,12 +3,14 @@ | |||||
#include "../libz80/z80.h" | #include "../libz80/z80.h" | ||||
#include "kernel.h" | #include "kernel.h" | ||||
#include "user.h" | #include "user.h" | ||||
#include "includes.h" | |||||
/* zasm reads from a specified blkdev, assemble the file and writes the result | /* zasm reads from a specified blkdev, assemble the file and writes the result | ||||
* in another specified blkdev. In our emulator layer, we use stdin and stdout | * in another specified blkdev. In our emulator layer, we use stdin and stdout | ||||
* as those specified blkdevs. | * as those specified blkdevs. | ||||
* | * | ||||
* This executable takes one argument: the path to a .cfs file to use for | |||||
* includes. | |||||
* | |||||
* Because the input blkdev needs support for Seek, we buffer it in the emulator | * Because the input blkdev needs support for Seek, we buffer it in the emulator | ||||
* layer. | * layer. | ||||
* | * | ||||
@@ -152,8 +154,12 @@ static void mem_write(int unused, uint16_t addr, uint8_t val) | |||||
mem[addr] = val; | mem[addr] = val; | ||||
} | } | ||||
int main() | |||||
int main(int argc, char *argv[]) | |||||
{ | { | ||||
if (argc > 2) { | |||||
fprintf(stderr, "Too many args\n"); | |||||
return 1; | |||||
} | |||||
// initialize memory | // initialize memory | ||||
for (int i=0; i<sizeof(KERNEL); i++) { | for (int i=0; i<sizeof(KERNEL); i++) { | ||||
mem[i] = KERNEL[i]; | mem[i] = KERNEL[i]; | ||||
@@ -161,10 +167,21 @@ int main() | |||||
for (int i=0; i<sizeof(USERSPACE); i++) { | for (int i=0; i<sizeof(USERSPACE); i++) { | ||||
mem[i+USER_CODE] = USERSPACE[i]; | mem[i+USER_CODE] = USERSPACE[i]; | ||||
} | } | ||||
for (int i=0; i<sizeof(FSDEV); i++) { | |||||
fsdev[i] = FSDEV[i]; | |||||
fsdev_size = 0; | |||||
if (argc == 2) { | |||||
FILE *fp = fopen(argv[1], "r"); | |||||
if (fp == NULL) { | |||||
fprintf(stderr, "Can't open file %s\n", argv[1]); | |||||
return 1; | |||||
} | |||||
int c = fgetc(fp); | |||||
while (c != EOF) { | |||||
fsdev[fsdev_size] = c; | |||||
fsdev_size++; | |||||
c = fgetc(fp); | |||||
} | |||||
fclose(fp); | |||||
} | } | ||||
fsdev_size = sizeof(FSDEV); | |||||
// read stdin in buffer | // read stdin in buffer | ||||
inpt_size = 0; | inpt_size = 0; | ||||
inpt_ptr = 0; | inpt_ptr = 0; | ||||
@@ -3,7 +3,7 @@ | |||||
set -e | set -e | ||||
set -o pipefail | set -o pipefail | ||||
ZASM=../../emul/zasm/zasm | |||||
ZASM=../../zasm.sh | |||||
RUNBIN=../../emul/runbin/runbin | RUNBIN=../../emul/runbin/runbin | ||||
for fn in *.asm; do | for fn in *.asm; do | ||||
@@ -2,7 +2,7 @@ | |||||
# no "set -e" because we test errors | # no "set -e" because we test errors | ||||
ZASM=../../emul/zasm/zasm | |||||
ZASM=../../zasm.sh | |||||
chkerr() { | chkerr() { | ||||
echo "Check that '$1' results in error $2" | echo "Check that '$1' results in error $2" | ||||
@@ -6,7 +6,7 @@ TMPFILE=$(mktemp) | |||||
SCAS=scas | SCAS=scas | ||||
KERNEL=../../../kernel | KERNEL=../../../kernel | ||||
APPS=../../../apps | APPS=../../../apps | ||||
ZASM=../../emul/zasm/zasm | |||||
ZASM=../../zasm.sh | |||||
ASMFILE=${APPS}/zasm/instr.asm | ASMFILE=${APPS}/zasm/instr.asm | ||||
cmpas() { | cmpas() { | ||||
@@ -0,0 +1,7 @@ | |||||
#!/bin/bash | |||||
# wrapper around ./emul/zasm/zasm that prepares includes CFS prior to call | |||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |||||
ZASMBIN="${DIR}/emul/zasm/zasm" | |||||
INCCFS="${DIR}/emul/zasm/includes.cfs" | |||||
"${ZASMBIN}" "${INCCFS}" |