1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-15 09:18:06 +11:00
collapseos/tools/emul/shell/shell_.asm

131 lines
1.9 KiB
NASM
Raw Normal View History

2019-05-10 02:58:41 +10:00
; named shell_.asm to avoid infinite include loop.
RAMSTART .equ 0x4000
RAMEND .equ 0x5000
STDIO_PORT .equ 0x00
FS_DATA_PORT .equ 0x01
FS_SEEKL_PORT .equ 0x02
FS_SEEKH_PORT .equ 0x03
2019-05-10 02:58:41 +10:00
jp init
2019-05-10 02:58:41 +10:00
#include "core.asm"
#include "parse.asm"
2019-05-10 02:58:41 +10:00
2019-05-17 22:14:19 +10:00
BLOCKDEV_RAMSTART .equ RAMSTART
2019-05-13 05:38:58 +10:00
BLOCKDEV_COUNT .equ 4
2019-05-10 02:58:41 +10:00
#include "blockdev.asm"
; List of devices
.dw emulGetC, emulPutC, 0, 0
.dw fsdevGetC, fsdevPutC, fsdevSeek, fsdevTell
2019-05-13 05:38:58 +10:00
.dw stdoutGetC, stdoutPutC, stdoutSeek, stdoutTell
.dw stdinGetC, stdinPutC, stdinSeek, stdinTell
2019-05-10 02:58:41 +10:00
#include "blockdev_cmds.asm"
2019-05-17 22:14:19 +10:00
STDIO_RAMSTART .equ BLOCKDEV_RAMEND
#include "stdio.asm"
.equ FS_RAMSTART STDIO_RAMEND
.equ FS_HANDLE_COUNT 2
#include "fs.asm"
2019-05-17 03:13:46 +10:00
#include "fs_cmds.asm"
SHELL_RAMSTART .equ FS_RAMEND
2019-05-13 05:38:58 +10:00
SHELL_EXTRA_CMD_COUNT .equ 7
2019-05-10 02:58:41 +10:00
#include "shell.asm"
2019-05-13 05:38:58 +10:00
.dw blkBselCmd, blkSeekCmd, fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd
init:
di
; setup stack
ld hl, RAMEND
ld sp, hl
2019-05-17 22:14:19 +10:00
xor a
ld de, BLOCKDEV_GETC
call blkSel
call stdioInit
call fsInit
ld a, 1 ; select fsdev
ld de, BLOCKDEV_GETC
call blkSel
call fsOn
xor a ; select ACIA
ld de, BLOCKDEV_GETC
call blkSel
call shellInit
jp shellLoop
2019-05-10 02:58:41 +10:00
emulGetC:
; Blocks until a char is returned
in a, (STDIO_PORT)
cp a ; ensure Z
ret
emulPutC:
out (STDIO_PORT), a
ret
fsdevGetC:
in a, (FS_DATA_PORT)
2019-05-13 05:38:58 +10:00
cp a ; ensure Z
ret
fsdevPutC:
out (FS_DATA_PORT), a
ret
fsdevSeek:
2019-05-13 05:38:58 +10:00
push af
ld a, l
out (FS_SEEKL_PORT), a
ld a, h
out (FS_SEEKH_PORT), a
2019-05-13 05:38:58 +10:00
pop af
ret
fsdevTell:
2019-05-13 05:38:58 +10:00
push af
in a, (FS_SEEKL_PORT)
ld l, a
in a, (FS_SEEKH_PORT)
ld h, a
2019-05-13 05:38:58 +10:00
pop af
ret
2019-05-13 05:38:58 +10:00
.equ STDOUT_HANDLE FS_HANDLES
stdoutGetC:
ld de, STDOUT_HANDLE
jp fsGetC
stdoutPutC:
ld de, STDOUT_HANDLE
jp fsPutC
stdoutSeek:
ld de, STDOUT_HANDLE
jp fsSeek
stdoutTell:
ld de, STDOUT_HANDLE
jp fsTell
.equ STDIN_HANDLE FS_HANDLES+FS_HANDLE_SIZE
stdinGetC:
ld de, STDIN_HANDLE
jp fsGetC
stdinPutC:
ld de, STDIN_HANDLE
jp fsPutC
stdinSeek:
ld de, STDIN_HANDLE
jp fsSeek
stdinTell:
ld de, STDIN_HANDLE
jp fsTell