mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 04:58:05 +11:00
recipes/sms/romasm: ed and zasm, fully functional!
This commit is contained in:
parent
22f9b4f07e
commit
c839703682
@ -18,6 +18,7 @@ This recipe is for installing a minimal Collapse OS system on the SMS. There
|
||||
are other recipes related to the SMS:
|
||||
|
||||
* [Interfacing a PS/2 keyboard](kbd/README.md)
|
||||
* [zasm and ed from ROM](romasm/README.md)
|
||||
|
||||
## Gathering parts
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
; 8K of onboard RAM
|
||||
.equ RAMSTART 0xc000
|
||||
; Memory register at the end of RAM. Must not overwrite
|
||||
.equ RAMEND 0xfdd0
|
||||
.equ RAMEND 0xddd0
|
||||
|
||||
jp init
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
#include "sms/kbd.asm"
|
||||
.equ KBD_RAMSTART RAMSTART
|
||||
.equ KBD_FETCHKC smskbdFetchKCA
|
||||
.equ KBD_FETCHKC smskbdFetchKCB
|
||||
#include "kbd.asm"
|
||||
|
||||
.equ VDP_RAMSTART KBD_RAMEND
|
||||
|
@ -13,3 +13,49 @@ compile them and run them.
|
||||
|
||||
* A SMS that can run Collapse OS.
|
||||
* A [PS/2 keyboard adapter](../kbd/README.md)
|
||||
|
||||
## Build
|
||||
|
||||
There's nothing special with building this recipe. Like the base recipe, run
|
||||
`make` then copy `os.sms` to your destination medium.
|
||||
|
||||
If you look at the makefile, however, you'll see that we use a new trick here:
|
||||
we embed "apps" binaries directly in our ROM so that we don't have to load them
|
||||
in memory.
|
||||
|
||||
## Usage
|
||||
|
||||
Alright, here's what we'll do: we'll author a source file, assemble it and run
|
||||
it, *all* on your SMS! Commands:
|
||||
|
||||
Collapse OS
|
||||
> fnew 1 src
|
||||
> ed src
|
||||
: 1i
|
||||
.org 0xc200
|
||||
: 1a
|
||||
ld hl, sFoo
|
||||
: 2a
|
||||
call 0x3f
|
||||
: 3a
|
||||
xor a
|
||||
: 4a
|
||||
ret
|
||||
: 5a
|
||||
sFoo: .db "foo", 0
|
||||
: w
|
||||
> fnew 1 dest
|
||||
> fopn 0 src
|
||||
> fopn 1 dest
|
||||
> zasm 1 2
|
||||
First pass
|
||||
Second pass
|
||||
> dest
|
||||
foo>
|
||||
|
||||
Awesome right? Some precisions:
|
||||
|
||||
* Our glue code specifies a `USER_RAMSTART` of `0xc200`. This is where
|
||||
`dest` is loaded by the `pgm` shell hook.
|
||||
* `0x3f` is the offset of `printstr` in the jump table of our glue code.
|
||||
* `xor a` is for the command to report as successful to the shell.
|
||||
|
@ -1,5 +1,6 @@
|
||||
; 8K of onboard RAM
|
||||
.equ RAMSTART 0xc000
|
||||
.equ USER_RAMSTART 0xc200
|
||||
; Memory register at the end of RAM. Must not overwrite
|
||||
.equ RAMEND 0xddd0
|
||||
|
||||
@ -53,8 +54,9 @@
|
||||
.equ STDIO_RAMSTART VDP_RAMEND
|
||||
#include "stdio.asm"
|
||||
|
||||
.equ MMAP_START 0xd800
|
||||
.equ MMAP_LEN RAMEND-MMAP_START
|
||||
.equ MMAP_START 0xd700
|
||||
; 0x180 is to leave some space for the stack
|
||||
.equ MMAP_LEN RAMEND-MMAP_START-0x180
|
||||
#include "mmap.asm"
|
||||
|
||||
.equ BLOCKDEV_RAMSTART STDIO_RAMEND
|
||||
@ -71,14 +73,20 @@
|
||||
#include "fs.asm"
|
||||
|
||||
.equ SHELL_RAMSTART FS_RAMEND
|
||||
.equ SHELL_EXTRA_CMD_COUNT 11
|
||||
.equ SHELL_EXTRA_CMD_COUNT 10
|
||||
#include "shell.asm"
|
||||
.dw edCmd, zasmCmd, fnewCmd, fdelCmd, fopnCmd, flsCmd, fsOnCmd, blkBselCmd
|
||||
.dw edCmd, zasmCmd, fnewCmd, fdelCmd, fopnCmd, flsCmd, blkBselCmd
|
||||
.dw blkSeekCmd, blkLoadCmd, blkSaveCmd
|
||||
|
||||
#include "blockdev_cmds.asm"
|
||||
#include "fs_cmds.asm"
|
||||
|
||||
.equ PGM_RAMSTART SHELL_RAMEND
|
||||
.equ PGM_CODEADDR USER_RAMSTART
|
||||
#include "pgm.asm"
|
||||
|
||||
.out PGM_RAMEND
|
||||
|
||||
init:
|
||||
di
|
||||
im 1
|
||||
@ -109,6 +117,8 @@ init:
|
||||
call vdpInit
|
||||
|
||||
call shellInit
|
||||
ld hl, pgmShellHook
|
||||
ld (SHELL_CMDHOOK), hl
|
||||
jp shellLoop
|
||||
|
||||
f0GetC:
|
||||
|
Loading…
Reference in New Issue
Block a user