From e18879fcb2ee696fd82ace17de4c8f0c3e8fdf9f Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Thu, 16 May 2019 13:23:23 -0400 Subject: [PATCH] zasm emul: hook fsdev in glue code --- tools/emul/zasm_glue.asm | 55 +++++++++++++++++++++++++++++++++++++++++------- tools/emul/zasm_user.asm | 20 +++++++++--------- 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/tools/emul/zasm_glue.asm b/tools/emul/zasm_glue.asm index befa8e1..aaac49e 100644 --- a/tools/emul/zasm_glue.asm +++ b/tools/emul/zasm_glue.asm @@ -3,8 +3,10 @@ .equ USER_CODE 0x4800 .equ STDIO_PORT 0x00 .equ STDIN_SEEK 0x01 +.equ FS_DATA_PORT 0x02 +.equ FS_SEEK_PORT 0x03 -jr init ; 2 bytes +jp init ; 3 bytes ; *** JUMP TABLE *** jp strncmp jp addDE @@ -17,11 +19,28 @@ jp findchar jp parseHexPair jp blkSel +#include "core.asm" +.equ BLOCKDEV_RAMSTART RAMSTART +.equ BLOCKDEV_COUNT 3 +#include "blockdev.asm" +; List of devices +.dw emulGetC, 0, emulSeek, emulTell +.dw 0, emulPutC, 0, 0 +.dw fsdevGetC, fsdevPutC, fsdevSeek, fsdevTell + +.equ FS_RAMSTART BLOCKDEV_RAMEND +.equ FS_HANDLE_COUNT 0 +#include "fs.asm" + init: di ; We put the stack at the end of the kernel memory ld hl, USER_CODE-1 ld sp, hl + ld a, 2 ; select fsdev + ld de, BLOCKDEV_GETC + call blkSel + call fsOn ld h, 0 ; input blkdev ld l, 1 ; output blkdev call USER_CODE @@ -59,10 +78,30 @@ emulTell: ld l, a ret -#include "core.asm" -.equ BLOCKDEV_RAMSTART RAMSTART -.equ BLOCKDEV_COUNT 2 -#include "blockdev.asm" -; List of devices -.dw emulGetC, 0, emulSeek, emulTell -.dw 0, emulPutC, 0, 0 +fsdevGetC: + in a, (FS_DATA_PORT) + cp a ; ensure Z + ret + +fsdevPutC: + out (FS_DATA_PORT), a + ret + +fsdevSeek: + push af + ld a, l + out (FS_SEEK_PORT), a + ld a, h + out (FS_SEEK_PORT), a + pop af + ret + +fsdevTell: + push af + in a, (FS_SEEK_PORT) + ld l, a + in a, (FS_SEEK_PORT) + ld h, a + pop af + ret + diff --git a/tools/emul/zasm_user.asm b/tools/emul/zasm_user.asm index ff78e2f..1bd53be 100644 --- a/tools/emul/zasm_user.asm +++ b/tools/emul/zasm_user.asm @@ -1,14 +1,14 @@ ; *** JUMP TABLE *** -JUMP_STRNCMP .equ 0x02 -JUMP_ADDDE .equ 0x05 -JUMP_ADDHL .equ 0x08 -JUMP_UPCASE .equ 0x0b -JUMP_UNSETZ .equ 0x0e -JUMP_INTODE .equ 0x11 -JUMP_INTOHL .equ 0x14 -JUMP_FINDCHAR .equ 0x17 -JUMP_PARSEHEXPAIR .equ 0x1a -JUMP_BLKSEL .equ 0x1d +JUMP_STRNCMP .equ 0x03 +JUMP_ADDDE .equ 0x06 +JUMP_ADDHL .equ 0x09 +JUMP_UPCASE .equ 0x0c +JUMP_UNSETZ .equ 0x0f +JUMP_INTODE .equ 0x12 +JUMP_INTOHL .equ 0x15 +JUMP_FINDCHAR .equ 0x18 +JUMP_PARSEHEXPAIR .equ 0x1b +JUMP_BLKSEL .equ 0x1e .equ USER_CODE 0x4800 .equ RAMSTART 0x5800