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

zasm emul: hook fsdev in glue code

This commit is contained in:
Virgil Dupras 2019-05-16 13:23:23 -04:00
parent df67a38f81
commit e18879fcb2
2 changed files with 57 additions and 18 deletions

View File

@ -3,8 +3,10 @@
.equ USER_CODE 0x4800 .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_SEEK_PORT 0x03
jr init ; 2 bytes jp init ; 3 bytes
; *** JUMP TABLE *** ; *** JUMP TABLE ***
jp strncmp jp strncmp
jp addDE jp addDE
@ -17,11 +19,28 @@ jp findchar
jp parseHexPair jp parseHexPair
jp blkSel 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: init:
di di
; We put the stack at the end of the kernel memory ; We put the stack at the end of the kernel memory
ld hl, USER_CODE-1 ld hl, USER_CODE-1
ld sp, hl ld sp, hl
ld a, 2 ; select fsdev
ld de, BLOCKDEV_GETC
call blkSel
call fsOn
ld h, 0 ; input blkdev ld h, 0 ; input blkdev
ld l, 1 ; output blkdev ld l, 1 ; output blkdev
call USER_CODE call USER_CODE
@ -59,10 +78,30 @@ emulTell:
ld l, a ld l, a
ret ret
#include "core.asm" fsdevGetC:
.equ BLOCKDEV_RAMSTART RAMSTART in a, (FS_DATA_PORT)
.equ BLOCKDEV_COUNT 2 cp a ; ensure Z
#include "blockdev.asm" ret
; List of devices
.dw emulGetC, 0, emulSeek, emulTell fsdevPutC:
.dw 0, emulPutC, 0, 0 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

View File

@ -1,14 +1,14 @@
; *** JUMP TABLE *** ; *** JUMP TABLE ***
JUMP_STRNCMP .equ 0x02 JUMP_STRNCMP .equ 0x03
JUMP_ADDDE .equ 0x05 JUMP_ADDDE .equ 0x06
JUMP_ADDHL .equ 0x08 JUMP_ADDHL .equ 0x09
JUMP_UPCASE .equ 0x0b JUMP_UPCASE .equ 0x0c
JUMP_UNSETZ .equ 0x0e JUMP_UNSETZ .equ 0x0f
JUMP_INTODE .equ 0x11 JUMP_INTODE .equ 0x12
JUMP_INTOHL .equ 0x14 JUMP_INTOHL .equ 0x15
JUMP_FINDCHAR .equ 0x17 JUMP_FINDCHAR .equ 0x18
JUMP_PARSEHEXPAIR .equ 0x1a JUMP_PARSEHEXPAIR .equ 0x1b
JUMP_BLKSEL .equ 0x1d JUMP_BLKSEL .equ 0x1e
.equ USER_CODE 0x4800 .equ USER_CODE 0x4800
.equ RAMSTART 0x5800 .equ RAMSTART 0x5800