Commit Graph

273 Commits

Author SHA1 Message Date
Virgil Dupras b56d6ca1c7 Rewrite uploadb.py in perl
I know, this is silly, but I'm moving tools to something a bit closer to the
system. I consider perl to be more system-like than python for a simple reason:
perl is part of the OpenBSD base system and python is not.

Also, I'm learning perl and using this as an opportunity.
2019-12-08 08:32:19 -05:00
Virgil Dupras 30a0f69101 Fix broken uploadb.py
putc didn't work well with any byte value on most terminal configuration. It
was a bad idea...
2019-12-02 22:57:22 -05:00
Virgil Dupras 270ad926c9 recipes/sms: use BASIC shell 2019-12-02 20:18:41 -05:00
Virgil Dupras 66dacd1816 tools/emul: add "Min SP" debug value
This gives the maximum size of the stack at any given moment during the
execution of the program. It's useful to figure out if the stack gets
dangerously close to the heap.
2019-12-02 17:44:54 -05:00
Virgil Dupras 2f07d849a8 tools/emul: deduplicate a little bit of C code 2019-12-02 17:28:01 -05:00
Virgil Dupras 572e3566eb Add upload tooling for BASIC shell 2019-11-30 22:36:14 -05:00
Virgil Dupras 871b06fecf bshell: adjust RAMSTART to avoid clashwith USER_CODE
With a 0x4000 RAMSTART, bshell's RAM usage clashed with USER_CODE, making
RAM-using userapp break everything.
2019-11-30 19:50:23 -05:00
Virgil Dupras 7c893dada1 basic: can now execute user apps!
Shell replacement sequence beginning in 3, 2, 1...
2019-11-25 22:05:10 -05:00
Virgil Dupras 12bc120375 basic: add bsel, bseek, getb, putb commands 2019-11-24 20:34:23 -05:00
Virgil Dupras e1df320d44 basic: add ldbas command 2019-11-24 14:26:32 -05:00
Virgil Dupras 13f935aa88 basic: add fls command
Also, add the new `bshell` emulated tool. BASIC is on its way to replace the
shell.
2019-11-24 10:24:15 -05:00
Virgil Dupras 585e9f3b6e tools/emul: add troubleshooting instructions in README
fixes #79
2019-11-23 15:22:26 -05:00
Virgil Dupras a680fd3328 basic: add support for signed integers 2019-11-23 14:56:23 -05:00
Virgil Dupras 43b450ca30 Update bootstrap binaries 2019-11-22 19:57:11 -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 cdd0b64570 Modify userspace .org and RAMSTART expectations
Instead of expecting a `USER_CODE` symbol to be set, we expect `.org` to be
set in all userspace glue code. This gives us more flexibility with regards to
how we manage that.

Moreover, instead of making `USER_RAMSTART` mandatory, we make it default to
the end of the binary, which is adequate in a majority of cases.

Will be useful for my upcoming mega-commit... :)
2019-11-15 10:33:13 -05:00
Virgil Dupras d74b85f146 zasm: allow .org to be specified from command line
Also important for upcoming mega commit...
2019-11-15 09:57:53 -05:00
Virgil Dupras e5255d22f9 zasm: make .org affect "@" symbol 2019-11-15 08:59:26 -05:00
Virgil Dupras 79e04189b0 Update bootstrap binaries 2019-11-14 21:25:11 -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 0e79035d9c Disable test failing on Travis 2019-11-13 22:37:00 -05:00
Virgil Dupras 69750b4da6 Update bootstrap binaries 2019-11-13 22:28:47 -05:00
Virgil Dupras 82995eb346 zasm: have .fill generate an error on overflow
Can possibly avoid a lot of debugging pain.
2019-11-13 22:27:48 -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 7274dccbe7 Move ASCII consts to ascii.h
And made them shorter in name. The new ascii.h file allow reuse in userspace
code.
2019-11-13 20:38:06 -05:00
Virgil Dupras f3992ed598 basic: begin an implementation from sratch
Let's see where it will lead us...
2019-11-13 15:28:16 -05:00
Virgil Dupras 1ae51bea3a tests: remove instr blacklist
Because scas isn't used as a reference anymore, no need to blacklist its bugs
anymore.
2019-11-12 20:47:09 -05:00
Virgil Dupras 4de2ce3ceb zasm: add RST instruction 2019-11-12 14:07:45 -05:00
Virgil Dupras cbc6fb5931 zasm: clean up jump table requirements
There was a little bit of cruft.
2019-11-11 20:21:13 -05:00
Virgil Dupras 17cc28e211 recipes/ti84: use a 3x5 font instead of a 5x7 one
This allow a lot more characters to fit on that tiny screen...

ref #41
2019-11-11 13:26:24 -05:00
Virgil Dupras 2bff486cd2 Update bootstrap binaries 2019-11-10 22:03:46 -05:00
Virgil Dupras 5f6b303e75 zasm: add IX/IY support to SRL, RR and RL 2019-11-10 22:03:18 -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 c4658591bd ti/lcd: allow for fonts smaller than 5 pixels
That's a lot of code for such a small change, but there's a big difference
between 5 pixels and 4 pixels: 4 pixels requires compositing.
2019-11-09 22:55:15 -05:00
Virgil Dupras a3c47f6272 Add tests for parseArgs 2019-11-08 10:53:52 -05:00
Virgil Dupras e972dfe220 Add test documentation 2019-11-08 10:37:52 -05:00
Virgil Dupras a13a94bbc7 fix typos 2019-11-07 12:13:00 -05:00
Virgil Dupras ca84b5dac8 recipes/ti84: first step
This was mostly lifted from my "tihello" example, but it required significant
adjustments.

This commit also introduces a font management system. A lot of fonts are
available online, but sources aren't always clear so to avoid copyright
landmines, I re-created my first 5x7 font from scratch.

As it is now, this resulting ROM gets "Collapse OS>" to be displayed on the
LCD screen. Much work still left to do.

ref #41
2019-11-07 11:52:29 -05:00
Virgil Dupras f395297874 Improve python tools' shebang
Most OS don't have python3 in /usr/bin/python...
2019-11-04 14:43:27 -05:00
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
Virgil Dupras a86234c87e Fix typo in shell's emul{Get,Put}C 2019-10-31 18:49:02 -04:00
Virgil Dupras b745f49186 Rename blockdev's API routines to GetB/PutB
The goal is to avoid mixing those routines with "character devices"
(acia, vpd, kbd) which aren't block devices and have routines that
have different expectations.

This is a first step to fixing #64.
2019-10-30 16:59:35 -04:00
Virgil Dupras a7aa2fc702 Improve test_parse_z coverage
Will help with #45
2019-10-20 18:19:02 -04:00
Virgil Dupras f41ccdbc81 Update bootstrap binaries 2019-10-17 15:47:39 -04:00
Virgil Dupras 3b1bbc1751 zasm: support negative displacement for IX/IY
Needed by #30.
2019-10-17 15:38:11 -04:00
Jorde Kang 5460f28cfb Removed unnecessary import sys (#46) 2019-10-15 22:41:44 -04:00
James Stanley 7f7251d57f Fix buffer overrun in shell emulator (#51) 2019-10-15 21:21:40 -04:00
Virgil Dupras 8926c33ab1 Fix tools/tests/zasm/runtests.sh shebang
It needs bash after all. On OpenBSD, /usr/sh works, but not on Ubuntu.
2019-10-10 15:22:21 -04:00
Keith Stellyes 4180b5873d Fix for tools/zasm.sh being dependent on readlink -f (an issue on macOS, preventing builds) (#28)
* Fix for tools/zasm.sh being dependent on readlink -f (an issue on macOS, preventing builds)

* Wrap zasm.sh shebang in /usr/bin/env ; remove comment about BSDs
2019-10-10 15:21:37 -04:00
Virgil Dupras 83b314c450 zasm: lower RAM requirements
I've tested RAM usage when self-assembling and there weren't as high
as I thought. zasm's defaults now use less than 0x1800 bytes of RAM,
making it possible, theoretically for now, for a Sega Master System
to assemble Collapse OS from within itself.
2019-10-06 15:42:09 -04:00
Virgil Dupras e4732d79dc zasm: tighten directive detection a bit 2019-10-06 14:39:47 -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 340a474941 emul/shell: use '@' symbol in jump table 2019-10-04 20:29:42 -04:00
Virgil Dupras 612323f714 zasm: add "last value" symbol (@) 2019-10-04 20:26:21 -04:00
Virgil Dupras d1735c3a73 zasm: remove last remnants of "old style" variables
This makes zasm suitable to run from ROM.
2019-07-25 14:02:04 -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 c2d84563dd zasm: allow duplicate const definition
This will allow interesting override scenarios, adding flexibility.
2019-07-23 16:01:23 -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 cdb206b7a5 zasm: fix nasty (iy+d) misparsing bug
*sob*...
2019-07-23 13:58:18 -04:00
Virgil Dupras b95f4c8c24 zasm: remove SYM_CTX_PTR 2019-07-22 16:34:40 -04:00
Virgil Dupras f4f91ebd79 zasm: remove SYM_CTX 2019-07-22 16:13:00 -04:00
Virgil Dupras 311d04e9aa zasm: make symbol registry easily parametrizable
I'm about to split the global registry in two (labels and consts)
and the previous state of registry selection made things murky.
Now it's much better.
2019-07-22 15:13:09 -04:00
Virgil Dupras 34f499184d zasm: add ".bin" directive
Also, remove zasm/test7 because it changes too much all time time
(whenever zasm changes) and isn't precise enough. Too much noise,
not worth it.
2019-07-21 12:58:02 -04:00
Virgil Dupras 01031a780a ed: Add 'w' command 2019-07-21 11:40:26 -04:00
Virgil Dupras 942d2a952d ed: take filename as an argument
This hard-binds ed to the filesystem (I liked the idea of working
only with blockdevs though...), but this is necessary for the
upcoming `w` command. We need some kind of way to tell the
destination to write to truncate itself.

This only has a meaning in the filesystem, but it's necessary to
let the file know that its registered file size has possibly
shrunk.

I thought of alternatives that would have allowed me to keep ed
blkdev-centered, but they were all too hackish to my own taste.

Hence, this new hard-bind on files.
2019-07-20 19:43:07 -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 a7afbe091e tools/tests: remove scas requirement
I'm about to break compatibility with scas. Before I do that, I
need to adjusts tests. Instead of running scas to compare results,
we commit expected result as binaries directly in the repo.
2019-07-20 17:13:57 -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 eefadc3917 ed: add support for 'a' and 'i' 2019-07-14 17:35:21 -04:00
Virgil Dupras e0f2a71dfc apps/ed: print specified line 2019-07-13 14:01:20 -04:00
Virgil Dupras 237d04fefd zasm: update bootstrap bin 2019-07-13 11:54:47 -04:00
Virgil Dupras 3491c26132 apps/ed: start implementing I/O 2019-07-13 11:29:06 -04:00
Virgil Dupras 3d474c9121 apps/ed: first steps 2019-07-13 09:57:37 -04:00
Virgil Dupras 252d71f1b8 Make tools/emul *BSD-friendly 2019-07-11 21:21:54 -04:00
Virgil Dupras ff7a114736 zasm: update bootstrap bin 2019-07-02 14:12:49 -04:00
Virgil Dupras 54b0602710 zasm: add support for RES and SET 2019-07-02 14:12:29 -04:00
Virgil Dupras 63486126ef zasm: update bootstrap bin 2019-07-01 10:56:38 -04:00
Virgil Dupras d6b391e39a Update bootstrap binaries 2019-06-19 13:22:51 -04:00
Virgil Dupras 7cdc288ef2 zasm: print progress indicator while assembling 2019-06-19 11:42:39 -04:00
Virgil Dupras 6f61aa404f tools/cfsunpack: new tool 2019-06-17 15:21:05 -04:00
Virgil Dupras 4b423a9dc6 tools/blkdump.py: new tool
Also, rename "download.py" to "memdump.py".
2019-06-17 09:02:01 -04:00
Virgil Dupras 3bc165c8f6 Update bootstrap bin 2019-06-15 20:54:27 -04:00
Virgil Dupras 3e7d181d3c zasm: properly raise error on bas ioPutC calls 2019-06-15 20:01:17 -04:00
Virgil Dupras 7ba8e85a4a Update bootstrap binaries 2019-06-15 15:53:03 -04:00
Virgil Dupras 4ea7839488 New tool: download.py 2019-06-14 16:06:18 -04:00
Virgil Dupras df5549ae76 tools/upload.py: support files larger than 0xff bytes 2019-06-14 15:06:14 -04:00
Virgil Dupras b742d48b75 Update bootstrap binaries 2019-06-05 19:52:56 -04:00
Virgil Dupras 3dde51ae98 Allow file-to-file compilation in the emulated shell 2019-06-05 19:51:19 -04:00
Virgil Dupras fc81bce70f Fix error handling when writing to files in emulated shell 2019-06-05 16:13:15 -04:00