From d9fff161571f2ece436601138d3316706bc27bbe Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 19 May 2019 09:14:40 -0400 Subject: [PATCH] zasm emul: get rid of the kernel/user distinction Made things complicated for nothing. --- apps/zasm/main.asm | 7 ++--- tools/emul/Makefile | 9 +++--- tools/emul/zasm/glue.asm | 28 +++-------------- tools/emul/zasm/user.asm | 68 ---------------------------------------- tools/emul/zasm/zasm.c | 5 --- 5 files changed, 11 insertions(+), 106 deletions(-) delete mode 100644 tools/emul/zasm/user.asm diff --git a/apps/zasm/main.asm b/apps/zasm/main.asm index b7412cc..7c01819 100644 --- a/apps/zasm/main.asm +++ b/apps/zasm/main.asm @@ -36,7 +36,7 @@ ; fsGetC ; fsSeek ; fsTell -; RAMSTART (where we put our variables in RAM) +; ZASM_RAMSTART (where we put our variables in RAM) ; FS_HANDLE_SIZE ; *** Variables *** @@ -45,7 +45,7 @@ ; about actual output, but only about the length of each upcode. This means ; that when we parse instructions and directive that error out because of a ; missing symbol, we don't error out and just write down a dummy value. -.equ ZASM_FIRST_PASS RAMSTART +.equ ZASM_FIRST_PASS ZASM_RAMSTART ; whether we're in "local pass", that is, in local label scanning mode. During ; this special pass, ZASM_FIRST_PASS will also be set so that the rest of the ; code behaves as is we were in the first pass. @@ -54,9 +54,6 @@ .equ ZASM_CTX_PC ZASM_LOCAL_PASS+1 .equ ZASM_RAMEND ZASM_CTX_PC+2 -; *** Code *** -jp zasmMain - #include "zasm/util.asm" .equ IO_RAMSTART ZASM_RAMEND #include "zasm/io.asm" diff --git a/tools/emul/Makefile b/tools/emul/Makefile index b8c0ce4..4e7a933 100644 --- a/tools/emul/Makefile +++ b/tools/emul/Makefile @@ -2,6 +2,8 @@ TARGETS = shell/shell zasm/zasm runbin/runbin KERNEL_HEADERS = shell/kernel.h zasm/kernel.h USER_HEADERS = zasm/user.h CFSPACK = ../cfspack/cfspack +PARTS = ../../parts/z80 +APPS = ../../apps .PHONY: all all: $(TARGETS) @@ -9,10 +11,7 @@ all: $(TARGETS) shell/kernel.h: shell/shell_.asm zasm/kernel.h: zasm/glue.asm $(KERNEL_HEADERS): - scas -o - -I ../../parts/z80 $< | ./bin2c.sh KERNEL | tee $@ > /dev/null - -zasm/user.h: zasm/user.asm - scas -o - -I ../../apps $< | ./bin2c.sh USERSPACE | tee $@ > /dev/null + scas -o - -I $(PARTS) -I $(APPS) $< | ./bin2c.sh KERNEL | tee $@ > /dev/null zasm/includes.cfs: $(CFSPACK) rm -rf zasm/includes @@ -27,7 +26,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 +zasm/zasm: zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/includes.h runbin/runbin: runbin/runbin.c libz80/libz80.o $(TARGETS): cc $< libz80/libz80.o -o $@ diff --git a/tools/emul/zasm/glue.asm b/tools/emul/zasm/glue.asm index 2ce84a6..d6290cf 100644 --- a/tools/emul/zasm/glue.asm +++ b/tools/emul/zasm/glue.asm @@ -1,31 +1,12 @@ ; 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 .equ FS_SEEK_PORT 0x03 .equ STDERR_PORT 0x04 -jp init ; 3 bytes -; *** JUMP TABLE *** -jp strncmp -jp addDE -jp addHL -jp upcase -jp unsetZ -jp intoDE -jp intoHL -jp writeHLinDE -jp findchar -jp parseHex -jp parseHexPair -jp blkSel -jp fsFindFN -jp fsOpen -jp fsGetC -jp fsSeek -jp fsTell +jp init #include "core.asm" #include "parse.asm" @@ -40,11 +21,12 @@ jp fsTell .equ FS_RAMSTART BLOCKDEV_RAMEND .equ FS_HANDLE_COUNT 0 #include "fs.asm" +.equ ZASM_RAMSTART FS_RAMEND +#include "zasm/main.asm" init: di - ; We put the stack at the end of the kernel memory - ld hl, USER_CODE-1 + ld hl, 0xffff ld sp, hl ld a, 2 ; select fsdev ld de, BLOCKDEV_GETC @@ -52,7 +34,7 @@ init: call fsOn ld h, 0 ; input blkdev ld l, 1 ; output blkdev - call USER_CODE + call zasmMain ; signal the emulator we're done halt diff --git a/tools/emul/zasm/user.asm b/tools/emul/zasm/user.asm deleted file mode 100644 index 7717434..0000000 --- a/tools/emul/zasm/user.asm +++ /dev/null @@ -1,68 +0,0 @@ -; *** JUMP TABLE *** -strncmp .equ 0x03 -addDE .equ 0x06 -addHL .equ 0x09 -upcase .equ 0x0c -unsetZ .equ 0x0f -intoDE .equ 0x12 -intoHL .equ 0x15 -writeHLinDE .equ 0x18 -findchar .equ 0x1b -parseHex .equ 0x1e -parseHexPair .equ 0x21 -blkSel .equ 0x24 -fsFindFN .equ 0x27 -fsOpen .equ 0x2a -fsGetC .equ 0x2d -fsSeek .equ 0x30 -fsTell .equ 0x33 - -.equ FS_HANDLE_SIZE 8 -.equ STDERR_PORT 0x04 -.equ USER_CODE 0x4800 -.equ RAMSTART 0x5800 -.org USER_CODE - - call zasmMain - ;call dumpSymTable - ret - -#include "zasm/main.asm" - -; *** Debug *** -debugPrint: - push af - push hl -.loop: - ld a, (hl) - or a - jr z, .end - out (STDERR_PORT), a - inc hl - jr .loop -.end: - ld a, 0x0a - out (STDERR_PORT), a - pop hl - pop af - ret - -dumpSymTable: - ld hl, SYM_NAMES - ld de, SYM_VALUES -.loop: - call debugPrint - ld a, (de) - out (12), a - inc de - ld a, (de) - out (12), a - inc de - xor a - call findchar - inc hl - ld a, (hl) - or a - ret z - jr .loop - diff --git a/tools/emul/zasm/zasm.c b/tools/emul/zasm/zasm.c index 19fe986..14deb08 100644 --- a/tools/emul/zasm/zasm.c +++ b/tools/emul/zasm/zasm.c @@ -2,7 +2,6 @@ #include #include "../libz80/z80.h" #include "kernel.h" -#include "user.h" #include "includes.h" /* zasm reads from a specified blkdev, assemble the file and writes the result @@ -26,7 +25,6 @@ */ // in sync with zasm_glue.asm -#define USER_CODE 0x4800 #define STDIO_PORT 0x00 #define STDIN_SEEK_PORT 0x01 #define FS_DATA_PORT 0x02 @@ -152,9 +150,6 @@ int main() for (int i=0; i