Commit Graph

51 Commits

Author SHA1 Message Date
Virgil Dupras 4b9712a224 avra: add branching instructions 2019-12-13 22:49:15 -05:00
Virgil Dupras e691dab070 zasm: little drive-by optimization
Use IX directly for argspec rows instead of going through DE. It saves a bit
of processing. The code was this way because I initially didn't use IX at all,
so as code evolved, that DE translation stayed as an artifact.
2019-12-13 10:54:01 -05:00
Virgil Dupras 4f7a05e3b7 core: remove cpHLDE
It wasn't used much, so I replaced its use in the kernel with direct code
and moved the routine in apps/ed, the only other place where it was used.
2019-12-12 15:53:14 -05:00
Virgil Dupras beaea6f978 basic: add puth command 2019-12-09 14:34:14 -05:00
Virgil Dupras d9db0a824e Make makefiles and shell scripts portable
It's no longer required to use `gmake` under OpenBSD and shell scripts
no longer require bash.
2019-12-09 09:45:22 -05:00
Virgil Dupras a680fd3328 basic: add support for signed integers 2019-11-23 14:56:23 -05:00
Virgil Dupras 2f71ad6d2f lib/expr: add left/right shifting operators 2019-11-22 18:35:10 -05:00
Virgil Dupras a03c5ac700 lib/expr: add bitwise operators 2019-11-22 17:16:51 -05:00
Virgil Dupras 972e8221f1 lib/expr: add division and modulo operators 2019-11-22 15:03:16 -05:00
Virgil Dupras 1b01f13105 lib/expr: refactor for easier operator addition 2019-11-22 14:45:12 -05:00
Virgil Dupras 7262993f14 basic: add if 2019-11-21 16:06:14 -05:00
Virgil Dupras f5b04fc02f basic: add expression support to print
Again, same thing as in zasm.
2019-11-18 15:52:44 -05:00
Virgil Dupras 0bd58fd178 basic: parse hex, binary and char literals
Same thing as in zasm.
2019-11-18 15:22:09 -05:00
Virgil Dupras 1cea6e71e0 basic: add a print cmd
It can only print a decimal literal. But still, that's a big step because
I hadn't implemented decimal formatting yet.
2019-11-18 13:40:23 -05:00
Virgil Dupras 019d05f64c Make the shell a userspace app
That's my mega-commit you've all been waiting for.

The code for the shell share more routines with userspace apps than with kernel
units, because, well, its behavior is that of a userspace app, not a device
driver.

This created a weird situation with libraries and jump tables. Some routine
belonging to the `kernel/` directory felt weird there.

And then comes `apps/basic`, which will likely share even more code with the
shell. I was seeing myself creating huge jump tables to reuse code from the
shell. It didn't feel right.

Moreover, we'll probably want basic-like apps to optionnally replace the shell.

So here I am with this huge change in the project structure. I didn't test all
recipes on hardware yet, I will do later. I might have broken some...

But now, the structure feels better and the line between what belongs to
`kernel` and what belongs to `apps` feels clearer.
2019-11-15 15:37:49 -05:00
Virgil Dupras e5255d22f9 zasm: make .org affect "@" symbol 2019-11-15 08:59:26 -05:00
Virgil Dupras 6e714875dc zasm: Constants now override labels at all times
Will be important for a mega-commit I'm preparing.
2019-11-14 21:16:36 -05:00
Virgil Dupras 7cf3ed38da Extract str.asm from core.asm and make core included by userspace
Most of register fiddling routines (which is now the only thing contained
in care.asm) are used by almost all userspace apps, often in inner loops.

That makes the penalty of using jump tables for those a bit too high.
Moreover, it burdens jump tables needlessly.

Because this unit is very small (now that string routines are out), it makes
sense to always include it in binaries.
2019-11-14 10:14:15 -05:00
Virgil Dupras 8d46895dd3 lib/parse: decimal ending with a whitespace are now valid
Also, make empty strings be parsed as invalid by parseDecimal.
2019-11-13 22:10:06 -05:00
Virgil Dupras 506c3d0a96 zasm: generalize handling of IX/IY in 0xcb upcode family
There's a couple of bit fiddling instructions that didn't have their
IX/IY variant implemented yet and without this commit, each of them
would have required a special routine. Not anymore.
2019-11-10 21:02:18 -05:00
Virgil Dupras d9d6093287 zasm: simplify (IX/Y+d) handling
We now require less special handling.
2019-11-10 20:16:50 -05:00
Virgil Dupras a3c47f6272 Add tests for parseArgs 2019-11-08 10:53:52 -05:00
Virgil Dupras a7aa2fc702 Improve test_parse_z coverage
Will help with #45
2019-10-20 18:19:02 -04:00
Virgil Dupras f4b6c7637d zasm: rename #inc to .inc
scas, it's not needed any more.
2019-10-06 14:32:23 -04:00
Virgil Dupras 612323f714 zasm: add "last value" symbol (@) 2019-10-04 20:26:21 -04:00
Virgil Dupras 1c6a7caeae recipes/sms/romasm: make zasm's memory usage fit the SMS 2019-07-23 16:50:19 -04:00
Virgil Dupras 1dec33e02a zasm: make symbol registry a bit more straightforward
Instead of strings of variable length driving the iteration of the
registry, we do so through records that keep track of lengths and
counts.
2019-07-23 15:21:42 -04:00
Virgil Dupras 02c7eb0161 zasm: clarify strlen's API 2019-07-23 14:59:38 -04:00
Virgil Dupras f4f91ebd79 zasm: remove SYM_CTX 2019-07-22 16:13:00 -04:00
Virgil Dupras fe15bafeca zasm: fix bug with registry selection
During expression parsing, if a local label was parsed, it would
select the local registry and keep that selection, making
subsequent global labels register in the wrong place.
2019-07-20 18:07:52 -04:00
Virgil Dupras 253674ea05 Fix broken tests
Also, make tests run in a *BSD environment
2019-07-19 14:24:35 -04:00
Virgil Dupras ae028e3a86 blockdev: make implementors "random access"
This huge refactoring remove the Seek and Tell routine from blockdev
implementation requirements and change GetC and PutC's API so that they
take an address to read and write (through HL/DE) at each call.

The "PTR" approach in blockdev implementation was very redundant from
device to device and it made more sense to generalize. It's possible
that future device aren't "random access", but we'll be able to add more
device types later.

Another important change in this commit is that the "blockdev handle" is
now opaque. Previously, consumers of the API would happily call routines
directly from one of the 4 offsets. We can't do that any more. This
makes the API more solid for future improvements.

This change forced me to change a lot of things in fs, but overall,
things are now simpler. No more `FS_PTR`: the "device handle" now holds
the active pointer.

Lots, lots of changes, but it also feels a lot cleaner and solid.
2019-06-04 15:36:20 -04:00
Virgil Dupras 9a72f10221 zasm: includes CFS is now built on-the-fly by zasm.sh
This makes for a much more usable zasm linux binary that doesn't have to
be rebuilt every time apps or kernel change.
2019-06-02 19:57:40 -04:00
Virgil Dupras 22e990ed89 Parametrize zasm linux bin's include CFS file
... instead of embedding it in the binary itself. Additionally, add a
"zasm.sh" wrapper to faciliate zasm calls on a linux machine.
2019-06-02 15:50:59 -04:00
Virgil Dupras 83771b538f fs: check for file size bounds in GetC 2019-05-31 11:12:29 -04:00
Virgil Dupras 328f44814e Make blockdev pointers 32 bits
This allows us to break through the 64K limit for includes CFS in zasm,
a limit we were dangerously close to breaking. In fact, this commit
makes us go over that limit. Right in time!
2019-05-28 19:42:35 -04:00
Virgil Dupras e414e600ea zasm: add ERR_DUPSYM and ERR_OOM error conditions 2019-05-27 17:45:05 -04:00
Virgil Dupras e18f9b53a9 zasm: add support for "$" symbol
Allows for the ".fill x-$" pattern.
2019-05-20 09:17:50 -04:00
Virgil Dupras ae315499cb Run unit tests with zasm 2019-05-20 07:50:23 -04:00
Virgil Dupras 7fad3b0c90 Move /parts/z80 to /kernel
Let go of that "meta os" thing. it's not as meta as I made it sound
like. It's a kernel.
2019-05-19 11:19:41 -04:00
Virgil Dupras 3b1ef2b9af zasm: bump global symbol limit to 0x200 2019-05-19 09:54:42 -04:00
Virgil Dupras 98695f9912 zasm: de-index symRegister
Make symRegister's logic pointer-based so we can break through the 0x100
limit.
2019-05-19 09:06:24 -04:00
Virgil Dupras d47d07757e zasm: fix expr operator priority 2019-05-18 15:17:56 -04:00
Virgil Dupras 068e4327ec zasm: fix false truncation error on "-" expressions 2019-05-18 14:51:11 -04:00
Virgil Dupras f44c3e5413 zasm: fix 3-digit hex parsing 2019-05-17 23:00:57 -04:00
Virgil Dupras cdb6cce914 zasm: add multiplication expressions 2019-05-17 22:22:10 -04:00
Virgil Dupras 28d5ebdc8a Make apps folder into a namespace
To straighten out includes and to pave the way into zasm being part of
the same "include CFS" as parts, we make zasm includes namespaced.
2019-05-17 20:22:32 -04:00
Virgil Dupras 072aad775a zasm: don't match prefixes in symFind
Only match when full names match.
2019-05-17 13:14:16 -04:00
Virgil Dupras 92a119105d zasm: add support for "0b" literals 2019-05-17 10:34:01 -04:00
Virgil Dupras 4075c90d44 Add unit test for zasm's parse unit 2019-05-17 10:00:30 -04:00