2019-06-03 13:34:16 -04:00
|
|
|
; classic RC2014 setup (8K ROM + 32K RAM) and a stock Serial I/O module
|
|
|
|
; The RAM module is selected on A15, so it has the range 0x8000-0xffff
|
|
|
|
.equ RAMSTART 0x8000
|
2019-06-17 13:44:36 -04:00
|
|
|
; kernel RAM usage, because of SDC, is a bit high and bring us almost to 0x8500
|
|
|
|
; We allocate at least 0x200 bytes for the stack, which is why we have this
|
|
|
|
; threshold.
|
|
|
|
.equ RAMEND 0x8700
|
2019-06-03 13:34:16 -04:00
|
|
|
.equ PGM_CODEADDR RAMEND
|
|
|
|
.equ ACIA_CTL 0x80 ; Control and status. RS off.
|
|
|
|
.equ ACIA_IO 0x81 ; Transmit. RS on.
|
|
|
|
|
|
|
|
jp init ; 3 bytes
|
|
|
|
|
|
|
|
; *** Jump Table ***
|
|
|
|
jp strncmp
|
|
|
|
jp upcase
|
|
|
|
jp findchar
|
|
|
|
jp parseHex
|
|
|
|
jp parseHexPair
|
|
|
|
jp blkSel
|
2019-06-06 22:16:28 -04:00
|
|
|
jp blkSet
|
2019-06-03 13:34:16 -04:00
|
|
|
jp fsFindFN
|
|
|
|
jp fsOpen
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsGetB
|
2019-06-03 13:34:16 -04:00
|
|
|
jp parseArgs
|
|
|
|
jp printstr
|
2019-10-30 16:59:35 -04:00
|
|
|
jp _blkGetB
|
|
|
|
jp _blkPutB
|
2019-06-04 11:53:02 -04:00
|
|
|
jp _blkSeek
|
|
|
|
jp _blkTell
|
2019-11-14 09:55:31 -05:00
|
|
|
jp printHexPair ; approaching 0x38...
|
|
|
|
|
|
|
|
; interrupt hook
|
|
|
|
.fill 0x38-$
|
|
|
|
jp aciaInt
|
|
|
|
|
|
|
|
; *** Jump Table (cont.) ***
|
2019-10-30 16:59:35 -04:00
|
|
|
jp sdcGetB
|
|
|
|
jp sdcPutB
|
|
|
|
jp blkGetB
|
2019-06-03 13:34:16 -04:00
|
|
|
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "err.h"
|
2019-11-13 20:38:06 -05:00
|
|
|
.inc "ascii.h"
|
2019-11-15 15:37:49 -05:00
|
|
|
.inc "blkdev.h"
|
|
|
|
.inc "fs.h"
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "core.asm"
|
2019-11-14 09:55:31 -05:00
|
|
|
.inc "str.asm"
|
2019-06-15 13:41:20 -04:00
|
|
|
.equ ACIA_RAMSTART RAMSTART
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "acia.asm"
|
2019-06-03 13:34:16 -04:00
|
|
|
.equ BLOCKDEV_RAMSTART ACIA_RAMEND
|
2019-06-07 19:53:50 -04:00
|
|
|
.equ BLOCKDEV_COUNT 4
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "blockdev.asm"
|
2019-06-03 13:34:16 -04:00
|
|
|
; List of devices
|
2019-10-30 16:59:35 -04:00
|
|
|
.dw sdcGetB, sdcPutB
|
|
|
|
.dw blk1GetB, blk1PutB
|
|
|
|
.dw blk2GetB, blk2PutB
|
|
|
|
.dw mmapGetB, mmapPutB
|
2019-06-03 13:34:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
.equ MMAP_START 0xe000
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "mmap.asm"
|
2019-06-03 13:34:16 -04:00
|
|
|
|
2019-06-04 11:53:02 -04:00
|
|
|
.equ STDIO_RAMSTART BLOCKDEV_RAMEND
|
2019-11-04 09:55:12 -05:00
|
|
|
.equ STDIO_GETC aciaGetC
|
|
|
|
.equ STDIO_PUTC aciaPutC
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "stdio.asm"
|
2019-06-03 13:34:16 -04:00
|
|
|
|
|
|
|
.equ FS_RAMSTART STDIO_RAMEND
|
2019-06-07 19:53:50 -04:00
|
|
|
.equ FS_HANDLE_COUNT 2
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "fs.asm"
|
2019-06-03 13:34:16 -04:00
|
|
|
|
2019-11-15 15:37:49 -05:00
|
|
|
; *** Shell ***
|
|
|
|
.inc "lib/util.asm"
|
|
|
|
.inc "lib/parse.asm"
|
|
|
|
.inc "lib/args.asm"
|
|
|
|
.inc "lib/stdio.asm"
|
2019-06-03 13:34:16 -04:00
|
|
|
.equ SHELL_RAMSTART FS_RAMEND
|
|
|
|
.equ SHELL_EXTRA_CMD_COUNT 11
|
2019-11-15 15:37:49 -05:00
|
|
|
.inc "shell/main.asm"
|
2019-06-03 13:34:16 -04:00
|
|
|
.dw sdcInitializeCmd, sdcFlushCmd
|
|
|
|
.dw blkBselCmd, blkSeekCmd, blkLoadCmd, blkSaveCmd
|
|
|
|
.dw fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd
|
|
|
|
|
2019-11-15 15:37:49 -05:00
|
|
|
.inc "shell/fs.asm"
|
|
|
|
.inc "shell/blkdev.asm"
|
2019-06-04 11:53:02 -04:00
|
|
|
|
2019-06-03 13:34:16 -04:00
|
|
|
.equ PGM_RAMSTART SHELL_RAMEND
|
2019-11-15 15:37:49 -05:00
|
|
|
.inc "shell/pgm.asm"
|
2019-06-03 13:34:16 -04:00
|
|
|
|
|
|
|
.equ SDC_RAMSTART PGM_RAMEND
|
|
|
|
.equ SDC_PORT_CSHIGH 6
|
|
|
|
.equ SDC_PORT_CSLOW 5
|
|
|
|
.equ SDC_PORT_SPI 4
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "sdc.asm"
|
2019-06-03 13:34:16 -04:00
|
|
|
|
|
|
|
.out SDC_RAMEND
|
|
|
|
|
|
|
|
init:
|
|
|
|
di
|
|
|
|
; setup stack
|
|
|
|
ld hl, RAMEND
|
|
|
|
ld sp, hl
|
|
|
|
im 1
|
|
|
|
call aciaInit
|
2019-06-17 13:44:36 -04:00
|
|
|
call fsInit
|
2019-06-03 13:34:16 -04:00
|
|
|
call shellInit
|
|
|
|
ld hl, pgmShellHook
|
|
|
|
ld (SHELL_CMDHOOK), hl
|
|
|
|
|
|
|
|
xor a
|
2019-06-04 09:56:36 -04:00
|
|
|
ld de, BLOCKDEV_SEL
|
2019-06-03 13:34:16 -04:00
|
|
|
call blkSel
|
|
|
|
|
|
|
|
ei
|
|
|
|
jp shellLoop
|
|
|
|
|
2019-06-07 19:53:50 -04:00
|
|
|
; *** blkdev 1: file handle 0 ***
|
2019-06-03 13:34:16 -04:00
|
|
|
|
2019-10-30 16:59:35 -04:00
|
|
|
blk1GetB:
|
2019-06-03 13:34:16 -04:00
|
|
|
ld ix, FS_HANDLES
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsGetB
|
2019-06-03 13:34:16 -04:00
|
|
|
|
2019-10-30 16:59:35 -04:00
|
|
|
blk1PutB:
|
2019-06-03 13:34:16 -04:00
|
|
|
ld ix, FS_HANDLES
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsPutB
|
2019-06-07 19:53:50 -04:00
|
|
|
|
|
|
|
; *** blkdev 2: file handle 1 ***
|
|
|
|
|
2019-10-30 16:59:35 -04:00
|
|
|
blk2GetB:
|
2019-06-07 19:53:50 -04:00
|
|
|
ld ix, FS_HANDLES+FS_HANDLE_SIZE
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsGetB
|
2019-06-07 19:53:50 -04:00
|
|
|
|
2019-10-30 16:59:35 -04:00
|
|
|
blk2PutB:
|
2019-06-07 19:53:50 -04:00
|
|
|
ld ix, FS_HANDLES+FS_HANDLE_SIZE
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsPutB
|