1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-02 06:20:55 +11:00
Commit Graph

1674 Commits

Author SHA1 Message Date
Clanmaster21
9cddaf1b59 String functions optimised (#86)
* String functions optimised

A few functions have been tweaked, but the biggest changes are in strlen, strskip and toWS, which take around two third of the cycles they used to (although strskip has more overhead). 10 bytes saved total.
toWS had two bytes added inlining the isWS call, and a jump to unsetZ was inlined too, saving a byte. This saved 29 cycles, with the original function being 90 cycles. I looked at other uses of isWS and it's difficult to inline it effectively in every situation, so I haven't inlined it elsewhere.
rdWS had a byte and two cycles saved by inlining a jump to unsetZ.
strskip is the same size, with the loop cut down from 35 cycles to 21 cycles, but 18 cycles are added outside the loop. I expect one character strings are in the minority, so this should save cycles overall.
strlen had 8 bytes saved, with the loop cut down from 38 cycles to 21 cycles, and 18 cycles removed outside the loop.

* Fixed strskip

Strskip wasn't preserving a properly. The new code uses the shadow af register, so whilst a byte and 4 cycles have been added outside the loop, it's safer and cleaner. The flags register isn't affected, but since the search goes for up to 64Kb I think it's safe to say the end of the string will always be reached.

* Remove inlining of isWS
2020-01-09 20:10:27 -05:00
Virgil Dupras
66744c0026 emul/hw/(ti|sms): fix compilation with gcc
It seems to be picky about where it accepts its link flags.
2020-01-09 08:36:29 -05:00
Virgil Dupras
6acd22492c emul/hw/sms: WIP
VDP kinda works. Can see the Collapse OS prompt with SMS base recipe
if `STDIO_GETC` gets replaced with infinite loop (no input emul yet).
2020-01-08 22:06:50 -05:00
Virgil Dupras
d70c6d3b5f sms/vdp: improve comments 2020-01-08 18:38:55 -05:00
Clanmaster21
927d5f2392 Reworked parseHexadecimal and parseDecimal, other minor tweaks (#85)
I've tweaked nearly every function in this file, so I'll go through them one by one.
parseDecimal has been reworked a little so that `a` can be used instead of `b` for checking for overflow. I had originally intended to redo it to work like the old parseDecimal, but I think the current method (once reworked a little) is cleaner and smaller, and should be just as fast. 7 bytes and 27 cycles saved.
parseHexadecimal has been changed to load hex digits into `b` `d` `c` `e` from the right (so all the digits move along to the left so the new digit can be inserted on the right), and then only at the end is any shifting done, using the faster `add a, a` to do left shifts. 9 bytes saved and 78 cycles saved inside the loop, and then 49 cycles added after the loop. 
parseBinaryLiteral had a few instructions moved around, saving two bytes and 5 cycles inside the loop, and a further 15 cycles saved on error.
parseLiteral has been reworked slightly, the isDigit call has been replaced with an inline parseDecimalDigit, saving a byte and around 20-30 cycles, with around 16 more cycles saved if the number is a decimal. The .char routine has been reduced by a byte, and 6 cycles saved on success, but 5 cycles added on error.
isDigit has been reduced by 4 bytes and 10 cycles on success, with a few more cycles saved on fail (hard to estimate due to branching).
2020-01-08 16:12:40 -05:00
Virgil Dupras
fb2117dc2e sms/vdp: use fonts from kernel/fnt
Instead of its own version of one. Additionally, add a 7x7 font to
the collection.
2020-01-07 22:15:35 -05:00
Virgil Dupras
439f880abe Rewrite font_compile.pl to C 2020-01-07 18:26:40 -05:00
Virgil Dupras
9a7617115f doc: add "Understanding the code" walkthrough 2020-01-05 10:47:23 -05:00
Virgil Dupras
c7ef8bf915 recipes: add "make emul" targets where appropriate 2020-01-02 16:59:38 -05:00
Virgil Dupras
9216057db8 emul/hw: add TI-84+ emulator
I implement the screen using XCB which is much more friendly
than z80e's SDL+CMake for development machines that want to install
minimal dependencies (for example, a port-less OpenBSD rig).
2020-01-01 22:48:01 -05:00
Virgil Dupras
25fc0a3c72 Add RC2014 classic emulation 2019-12-31 22:03:48 -05:00
Virgil Dupras
eed67c4768 tests/shell: bring back the static test.cfs
I had forgotten about that ordering thing: depending on the platform
cfspack doesn't read files in a directory in the same order.
2019-12-31 15:17:22 -05:00
Virgil Dupras
359991c005 cfspack: fix compilation error
Some compilers don't like assigning stdout statically.
2019-12-31 15:12:17 -05:00
Virgil Dupras
097c677641 emul/zasm: use libcfs
This allows us to get rid of the zasm.sh wrapper.
2019-12-31 15:07:39 -05:00
Virgil Dupras
4cde58fd83 cfspack: make into a library
Use it in shell instead of using popen()
2019-12-31 13:57:52 -05:00
Virgil Dupras
72357fec86 Move "emul" folder to root 2019-12-31 13:34:24 -05:00
Virgil Dupras
40f56dd6dc cfspack: silence compilation warning 2019-12-31 13:08:24 -05:00
Virgil Dupras
c5c6ef4c6c Move "tests" folder to root 2019-12-31 13:07:05 -05:00
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
73a5275b1e lib/parse: make parseBinaryLiteral "tail" HL 2019-12-30 13:05:21 -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
5f2615a134 at28w: don't use lib/args 2019-12-29 21:02:04 -05:00
Virgil Dupras
346bcc3d3d zasm: don't use lib/args
This unit is being removed.
2019-12-29 20:56:13 -05:00
Virgil Dupras
d0f031939f lib/parse: make parseLiteral a little tighter
Sub-parsers are seldom used by themselves, except for parseDecimal.
I'm tightening the code of this unit for two reasons:

1. Optimization
2. Upcoming API change where HL won't be preserved anymore, but will
   point to char following the last parse char. This will allow us
   to simplify lib/expr.
2019-12-29 19:47:19 -05:00
Virgil Dupras
15628da7de lib/expr: make EXPR_PARSE put result in DE instead of IX
Finally getting rid of this bad mistake of using IX for this.
2019-12-29 17:37:04 -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
5301200d6f basic: parseExpr --> parseExprDE 2019-12-23 19:01:03 -05:00
Virgil Dupras
476178ee7c zasm: parseExpr --> parseExprDE 2019-12-23 18:44:55 -05:00
Virgil Dupras
025b90909f Update bootstrap bin 2019-12-23 16:03:23 -05:00
Virgil Dupras
aef96c5e96 Add missing common.asm test harness file 2019-12-23 16:02:26 -05:00
Virgil Dupras
cc754e12aa parseExpr --> parseExprDE: easy ones
Those replacements were trivially equivalent. For the other ones, an
examination of the context is necessary.
2019-12-23 15:59:55 -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
98ca338aba avra: add LD/ST 2019-12-22 21:50:20 -05:00
Virgil Dupras
51e500e8da avra: avoid pgm addr truncation error on first pass 2019-12-22 19:44:46 -05:00
Virgil Dupras
b955a67daa avra: add TST 2019-12-22 19:24:36 -05:00
Virgil Dupras
6e1e8e0e59 avra: add LSL 2019-12-22 18:36:15 -05:00
Virgil Dupras
8ded02bc78 avra: fix misordered MOV, MUL, NEG and NOP 2019-12-22 18:35:08 -05:00
Virgil Dupras
f54e10f9fd avra: add CALL and JMP 2019-12-22 15:54:46 -05:00
Virgil Dupras
10b925e0e0 avra: add BCLR and BSET 2019-12-22 15:11:15 -05:00
Virgil Dupras
1771ee8da7 avra: add SER 2019-12-22 15:01:08 -05:00
Virgil Dupras
0a9ac27cf6 avra: add SBIC and SBIS 2019-12-22 14:55:38 -05:00
Virgil Dupras
a9dcba5793 avra: add CBR instruction 2019-12-22 14:45:10 -05:00
Virgil Dupras
c968995ec0 avra: add CBI and SBI
This completes instruction support for the Blink tn45 example.
2019-12-15 20:51:31 -05:00