Decouple shell from acia

This commit is contained in:
Virgil Dupras 2019-04-14 14:24:29 -04:00
parent 8ccddbcb0e
commit 461c09f1e5
4 changed files with 31 additions and 8 deletions

View File

@ -35,4 +35,18 @@ Thus, code that glue parts together coould look like:
MOD2_RAMSTART .equ MOD1_RAMEND
#include "mod2.asm"
## Code style
The asm code used in these parts is heavily dependent on what scas offers. I
try to be as "low-tech" as possible because the implementation of the assembler
to be implemented for the z80 will likely be more limited. For example, I try
to avoid macros.
One exception, however, is for the routine hooks (`SHELL_GETC` for example). At
first, I wanted to assign a label to a const (`SHELL_GETC .equ aciaGetC` for
example), but it turns out that scas doesn't support this (but it could: label
addresses are known at compile time and thus can be consts (maybe at the cost
of an extra pass though)). I went for macros instead, but that doesn't mean
that the z80 assembler will need to support macros. It just need to support
labels-as-consts.
[scas]: https://github.com/KnightOS/scas

View File

@ -115,7 +115,7 @@ aciaGetC:
call aciaIncIndex
ld (ACIA_BUFRDIDX), a
; And finially, fetch the value.
; And finally, fetch the value.
ld a, (de)
pop de

View File

@ -1,20 +1,23 @@
; shell
;
; Runs a shell over an asynchronous communication interface adapter (ACIA).
; for now, this unit is tightly coupled to acia.asm, but it will eventually be
; more general than that.
; Runs a shell over an block device interface.
; Status: incomplete. As it is now, it spits a welcome prompt, wait for input
; and compare the first 4 chars of the input with a command table and call the
; appropriate routine if it's found, an error if it's not.
;
; Commands, for now, are dummy.
; Commands, for now, are partially implemented.
;
; See constants below for error codes.
;
; All numerical values in the Collapse OS shell are represented and parsed in
; hexadecimal form, without prefix or suffix.
; *** DEFINES ***
; SHELL_GETC: Macro that calls a GetC routine
; SHELL_PUTC: Macro that calls a PutC routine
; SHELL_RAMSTART
; *** CONSTS ***
; number of entries in shellCmdTbl
@ -61,7 +64,7 @@ shellInit:
shellLoop:
; First, let's wait until something is typed.
call aciaGetC
SHELL_GETC
; got it. Now, is it a CR or LF?
cp ASCII_CR
jr z, .do ; char is CR? do!
@ -100,9 +103,9 @@ shellLoop:
printcrlf:
ld a, ASCII_CR
call aciaPutC
SHELL_PUTC
ld a, ASCII_LF
call aciaPutC
SHELL_PUTC
ret
; Parse command (null terminated) at HL and calls it

View File

@ -67,6 +67,8 @@ init:
ACIA_RAMSTART .equ RAMSTART
#include "acia.asm"
SHELL_RAMSTART .equ ACIA_RAMEND
.define SHELL_GETC call aciaGetC
.define SHELL_PUTC call aciaPutC
#include "shell.asm"
```
@ -89,6 +91,10 @@ What comes below is actual code include from parts we want to include in our
OS. As you can see, we need to tell each module where to put their variables.
See `parts/README.md` for details.
You can also see from the `SHELL_GETC` and `SHELL_PUTC` macros that the shell
is decoupled from the ACIA and can get its IO from anything. See
`parts/README.md` for details.
### Build the image
We only have the shell to build, so it's rather straightforward: