collapseos/recipes/sms/romasm
Virgil Dupras 2a55bfd375 stdio: remove a layer of indirection in GetC/PutC
We use zasm's ability to use labels in .equ directive.

We didn't do it before because for a while, we were in between scas
and zasm (scas was used in automated tests) so we needed to use the
lowest common denominator: zasm doesn't have macros and scas can't
use labels in .equ directives.

This forced us to add this layer of indirection. But now that we are
completely cut from scas' dependency, we can use this nice zasm's
ability.
2019-11-04 09:55:12 -05:00
..
.gitignore
glue.asm stdio: remove a layer of indirection in GetC/PutC 2019-11-04 09:55:12 -05:00
Makefile recipes/sms/romasm: adjust ed/zasm offsets 2019-07-22 10:11:59 -04:00
README.md recipes/sms/romasm: ed and zasm, fully functional! 2019-07-25 14:24:18 -04:00
user-tmpl.h Rename blockdev's API routines to GetB/PutB 2019-10-30 16:59:35 -04:00

zasm and ed from ROM

SMS' RAM is much tighter than in the RC2014, which makes the idea of loading apps like zasm and ed in memory before using it a bit wasteful. In this recipe, we'll include zasm and ed code directly in the kernel and expose them as shell commands.

Moreover, we'll carve ourselves a little 1K memory map to put a filesystem in there. This will give us a nice little system that can edit small source files compile them and run them.

Gathering parts

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.