mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-11 08:38: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:
|
are other recipes related to the SMS:
|
||||||
|
|
||||||
* [Interfacing a PS/2 keyboard](kbd/README.md)
|
* [Interfacing a PS/2 keyboard](kbd/README.md)
|
||||||
|
* [zasm and ed from ROM](romasm/README.md)
|
||||||
|
|
||||||
## Gathering parts
|
## Gathering parts
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
; 8K of onboard RAM
|
; 8K of onboard RAM
|
||||||
.equ RAMSTART 0xc000
|
.equ RAMSTART 0xc000
|
||||||
; Memory register at the end of RAM. Must not overwrite
|
; Memory register at the end of RAM. Must not overwrite
|
||||||
.equ RAMEND 0xfdd0
|
.equ RAMEND 0xddd0
|
||||||
|
|
||||||
jp init
|
jp init
|
||||||
|
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "sms/kbd.asm"
|
#include "sms/kbd.asm"
|
||||||
.equ KBD_RAMSTART RAMSTART
|
.equ KBD_RAMSTART RAMSTART
|
||||||
.equ KBD_FETCHKC smskbdFetchKCA
|
.equ KBD_FETCHKC smskbdFetchKCB
|
||||||
#include "kbd.asm"
|
#include "kbd.asm"
|
||||||
|
|
||||||
.equ VDP_RAMSTART KBD_RAMEND
|
.equ VDP_RAMSTART KBD_RAMEND
|
||||||
|
@ -13,3 +13,49 @@ compile them and run them.
|
|||||||
|
|
||||||
* A SMS that can run Collapse OS.
|
* A SMS that can run Collapse OS.
|
||||||
* A [PS/2 keyboard adapter](../kbd/README.md)
|
* 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
|
; 8K of onboard RAM
|
||||||
.equ RAMSTART 0xc000
|
.equ RAMSTART 0xc000
|
||||||
|
.equ USER_RAMSTART 0xc200
|
||||||
; Memory register at the end of RAM. Must not overwrite
|
; Memory register at the end of RAM. Must not overwrite
|
||||||
.equ RAMEND 0xddd0
|
.equ RAMEND 0xddd0
|
||||||
|
|
||||||
@ -53,8 +54,9 @@
|
|||||||
.equ STDIO_RAMSTART VDP_RAMEND
|
.equ STDIO_RAMSTART VDP_RAMEND
|
||||||
#include "stdio.asm"
|
#include "stdio.asm"
|
||||||
|
|
||||||
.equ MMAP_START 0xd800
|
.equ MMAP_START 0xd700
|
||||||
.equ MMAP_LEN RAMEND-MMAP_START
|
; 0x180 is to leave some space for the stack
|
||||||
|
.equ MMAP_LEN RAMEND-MMAP_START-0x180
|
||||||
#include "mmap.asm"
|
#include "mmap.asm"
|
||||||
|
|
||||||
.equ BLOCKDEV_RAMSTART STDIO_RAMEND
|
.equ BLOCKDEV_RAMSTART STDIO_RAMEND
|
||||||
@ -71,14 +73,20 @@
|
|||||||
#include "fs.asm"
|
#include "fs.asm"
|
||||||
|
|
||||||
.equ SHELL_RAMSTART FS_RAMEND
|
.equ SHELL_RAMSTART FS_RAMEND
|
||||||
.equ SHELL_EXTRA_CMD_COUNT 11
|
.equ SHELL_EXTRA_CMD_COUNT 10
|
||||||
#include "shell.asm"
|
#include "shell.asm"
|
||||||
.dw edCmd, zasmCmd, fnewCmd, fdelCmd, fopnCmd, flsCmd, fsOnCmd, blkBselCmd
|
.dw edCmd, zasmCmd, fnewCmd, fdelCmd, fopnCmd, flsCmd, blkBselCmd
|
||||||
.dw blkSeekCmd, blkLoadCmd, blkSaveCmd
|
.dw blkSeekCmd, blkLoadCmd, blkSaveCmd
|
||||||
|
|
||||||
#include "blockdev_cmds.asm"
|
#include "blockdev_cmds.asm"
|
||||||
#include "fs_cmds.asm"
|
#include "fs_cmds.asm"
|
||||||
|
|
||||||
|
.equ PGM_RAMSTART SHELL_RAMEND
|
||||||
|
.equ PGM_CODEADDR USER_RAMSTART
|
||||||
|
#include "pgm.asm"
|
||||||
|
|
||||||
|
.out PGM_RAMEND
|
||||||
|
|
||||||
init:
|
init:
|
||||||
di
|
di
|
||||||
im 1
|
im 1
|
||||||
@ -109,6 +117,8 @@ init:
|
|||||||
call vdpInit
|
call vdpInit
|
||||||
|
|
||||||
call shellInit
|
call shellInit
|
||||||
|
ld hl, pgmShellHook
|
||||||
|
ld (SHELL_CMDHOOK), hl
|
||||||
jp shellLoop
|
jp shellLoop
|
||||||
|
|
||||||
f0GetC:
|
f0GetC:
|
||||||
|
Loading…
Reference in New Issue
Block a user