Commit Graph

63 Commits

Author SHA1 Message Date
Virgil Dupras e3c885085d Consolidate tests
Also, removed leftover in runbin.c (what did it do there??) that
could result in tests falsely passing.
2019-12-30 20:08:08 -05:00
Virgil Dupras 7ca54d179d lib/expr: make EXPR_PARSE "tail" HL
Things are now much simpler.
2019-12-30 19:24:53 -05:00
Virgil Dupras 289037a3dd lib/parse: make parseDecimal "tail" HL
HL, instead of being preserved, is set to the character following
the last read character.
2019-12-30 10:13:55 -05:00
Virgil Dupras dcb96aefe9 lib/parse: remove parseHexPair
Also, make parseHexadecimal "tail" (HL). Soon, all routines in lib/parse
will do that, making the life of lib/expr easier.
2019-12-29 21:56:56 -05:00
Virgil Dupras 2503bdfced lib/args: remove 2019-12-29 21:05:09 -05:00
Virgil Dupras 981c93bfd4 lib/expr: fix stack imbalance on failure 2019-12-29 16:15:48 -05:00
Virgil Dupras 4760d044c0 test_expr: simplify 2019-12-29 15:39:39 -05:00
Virgil Dupras 213614af33 lib/expr: make recursion process a bit more orderly
Instead of going left and right, finding operators chars and replacing them
with nulls, we parse expressions in a more orderly manner, one chunk at a
time. I think it qualifies as "recursive descent", but I'm not sure.

This allows us to preserve the string we parse and should also make the
implementation of parens much easier.
2019-12-29 11:42:18 -05:00
Virgil Dupras 7410891ad1 lib/expr: fix unary minus
For some reason, I've mistakenly disabled tests in test_expr without noticing
and I also broke "-123" parsing. Fixed.
2019-12-23 20:53:31 -05:00
Virgil Dupras 6d88c3a754 parseExprDE --> parseExpr 2019-12-23 19:13:44 -05:00
Virgil Dupras aef96c5e96 Add missing common.asm test harness file 2019-12-23 16:02:26 -05:00
Virgil Dupras a034f63e23 test: begin adding common test harnessing code
This should make tests a bit more convenient to write and debug.

Moreover, begin de de-IX-ization of parseExpr. I have, in a local WIP, a
parseExpr implemented using a recursive descent algo, it passes all tests, but
it unfortunately assembles a faulty zasm. I have to find the expressions that
it doesn't parse properly.

But before I do that, I prefer to commit these significant improvements I've
been making to tests harness in parallel of this development.
2019-12-23 15:41:25 -05:00
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