@@ -35,4 +35,18 @@ Thus, code that glue parts together coould look like: | |||||
MOD2_RAMSTART .equ MOD1_RAMEND | MOD2_RAMSTART .equ MOD1_RAMEND | ||||
#include "mod2.asm" | #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 | [scas]: https://github.com/KnightOS/scas |
@@ -115,7 +115,7 @@ aciaGetC: | |||||
call aciaIncIndex | call aciaIncIndex | ||||
ld (ACIA_BUFRDIDX), a | ld (ACIA_BUFRDIDX), a | ||||
; And finially, fetch the value. | |||||
; And finally, fetch the value. | |||||
ld a, (de) | ld a, (de) | ||||
pop de | pop de | ||||
@@ -1,20 +1,23 @@ | |||||
; shell | ; 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 | ; 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 | ; 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. | ; 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. | ; See constants below for error codes. | ||||
; | ; | ||||
; All numerical values in the Collapse OS shell are represented and parsed in | ; All numerical values in the Collapse OS shell are represented and parsed in | ||||
; hexadecimal form, without prefix or suffix. | ; 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 *** | ; *** CONSTS *** | ||||
; number of entries in shellCmdTbl | ; number of entries in shellCmdTbl | ||||
@@ -61,7 +64,7 @@ shellInit: | |||||
shellLoop: | shellLoop: | ||||
; First, let's wait until something is typed. | ; First, let's wait until something is typed. | ||||
call aciaGetC | |||||
SHELL_GETC | |||||
; got it. Now, is it a CR or LF? | ; got it. Now, is it a CR or LF? | ||||
cp ASCII_CR | cp ASCII_CR | ||||
jr z, .do ; char is CR? do! | jr z, .do ; char is CR? do! | ||||
@@ -100,9 +103,9 @@ shellLoop: | |||||
printcrlf: | printcrlf: | ||||
ld a, ASCII_CR | ld a, ASCII_CR | ||||
call aciaPutC | |||||
SHELL_PUTC | |||||
ld a, ASCII_LF | ld a, ASCII_LF | ||||
call aciaPutC | |||||
SHELL_PUTC | |||||
ret | ret | ||||
; Parse command (null terminated) at HL and calls it | ; Parse command (null terminated) at HL and calls it | ||||
@@ -67,6 +67,8 @@ init: | |||||
ACIA_RAMSTART .equ RAMSTART | ACIA_RAMSTART .equ RAMSTART | ||||
#include "acia.asm" | #include "acia.asm" | ||||
SHELL_RAMSTART .equ ACIA_RAMEND | SHELL_RAMSTART .equ ACIA_RAMEND | ||||
.define SHELL_GETC call aciaGetC | |||||
.define SHELL_PUTC call aciaPutC | |||||
#include "shell.asm" | #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. | OS. As you can see, we need to tell each module where to put their variables. | ||||
See `parts/README.md` for details. | 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 | ### Build the image | ||||
We only have the shell to build, so it's rather straightforward: | We only have the shell to build, so it's rather straightforward: | ||||