Commit Graph
54 Commits
Author SHA1 Message Date
starcells 1af92eb156 r8asm: make .loop consume the bit it just cleared
.endloop expanded to >-+]< : flb clears the LSB and rnz then tests that
very same bit, so it always sees 0 and the body ran exactly once no
matter how many 1s the counter cell held.  Measured: a counter of 0b111
came out as 0b110 after a single pass.

Putting a ror after the flb pulls the next bit down before the test,
which is what SPEC describes -- consecutive 1s from the LSB, one per
iteration.  Measured:
    0b0000_0111 -> 3 passes, counter 0
    0b1111_1111 -> 8 passes, counter 0 (a bare ror would spin forever)
Nothing under asm/ uses .loop, so no existing tape changes.
2026-11-05 22:49:54 +08:00
starcells 3f3e431d64 r8asm: say what is wrong instead of dying or lying
A typo used to end in one of three ways: std::out_of_range aborting the
process (unknown macro, unknown directive), a silent 0 (unknown name used
as an address, which quietly mis-assembles), or a silent empty tape (a
file or %include that could not be opened).  All four now go through
ast::fail(), print a line on stderr, set the error flag and make the CLI
exit with 1.  Names that are reported repeatedly are only printed once.

While here: import_file set the cell size *after* parsing, so the
%include handler read main_tree.CELL_SIZE before it had ever been set and
handed 0 to included files.  It worked by accident because the top-level
call ran again at the end.  Moved it before the parse.

r8asm_test.cc came from the working tree (argv instead of a hard-coded
path); it now also checks the arguments and the error flag.
2026-11-05 22:49:54 +08:00
starcells f68d68d497 build: stop throwing the compiler's default flags away
set(CMAKE_CXX_FLAGS ...) replaced the whole flag set.  On MSVC that
dropped /EHsc, which this code needs (std::map::at, std::stoi throw), and
it applied -O3 to every configuration -- a Debug build then passes /RTC1
and MSVC refuses to combine that with an optimisation level (D8016).

CMake's Release configuration already passes -O3 / /O2 and defines
NDEBUG, so the block is gone.  The only flag worth keeping is
-march=native, and only for a Release build of a non-MSVC compiler.

Also cast the cell-size constants so the size_t -> int32_t narrowing
warnings go away.
2026-11-05 22:49:54 +08:00
starcells 4927c7779d asm: add a fibonacci demo that does not hard-code 8 bits
The counter is _CELL_MAX ones and one bit is eaten per round, so the loop runs _CELL_SIZE times on any width, and the address layout is built from a named UNIT instead of scattered 2s. Verified against ROT-8: 1 1 2 3 5 8 13 21 34 55.
2026-11-05 22:43:07 +08:00
starcells 48b07a3af8 202609200919 2026-09-20 09:19:07 +08:00
starcells 99e666be48 202609200918 2026-09-20 09:18:37 +08:00
starcells 3a209673fe Filled SPEC.md 2026-09-20 09:16:47 +08:00
starcells 10b29000d6 [tmp]202609162143 2026-09-16 21:43:58 +08:00
starcells bef8310558 README added 2026-09-14 21:01:48 +08:00
starcells 7c57f4e628 202609131316 2026-09-13 13:16:47 +08:00
starcells 2469c3aa54 Fixed raw_xor 2026-09-13 13:01:17 +08:00
starcells 4014a8fab3 Adjusted macro names 2026-09-13 12:39:17 +08:00
starcells ebe98fdfa8 [err]202609131217 2026-09-13 12:17:41 +08:00
starcells ed4ce6d3d4 [tmp]202609121939 2026-09-12 19:39:57 +08:00
starcells 208e37c394 202608290145 2026-08-29 01:45:27 +08:00
starcells 8f22841144 FIRST WORKABLE VERSION 2026-08-29 01:41:57 +08:00
starcells 57905c1cf1 First test with real asm files 2026-08-29 01:33:28 +08:00
starcells ef77c07819 202608290119 2026-08-29 01:20:03 +08:00
starcells 6130e5d54a 202608290040 2026-08-29 00:40:39 +08:00
starcells fa6566b0e8 202608290036 2026-08-29 00:36:39 +08:00
starcells ff470cf677 202608290026 2026-08-29 00:26:35 +08:00
starcells 5aa4893dc6 202608290010 2026-08-29 00:10:20 +08:00
starcells a96e7ffa87 202608280153 2026-08-28 01:53:22 +08:00
starcells 68e6006fa5 PARSER FINISHED 2026-08-28 01:44:27 +08:00
starcells 75c86d43c0 202608280140 2026-08-28 01:40:57 +08:00
starcells 7c2721bdaa 202608280137 2026-08-28 01:38:01 +08:00
starcells 37e503fa8a 202608280132 2026-08-28 01:32:11 +08:00
starcells 5b53bc91be 202608280129 2026-08-28 01:29:11 +08:00
starcells c44a4058d1 202608280123 2026-08-28 01:23:16 +08:00
starcells 1fc3c6722f 202608280051 2026-08-28 00:51:40 +08:00
starcells 10a793e2db 202608280013 2026-08-28 00:13:13 +08:00
starcells 27cf3e2051 202608271423 2026-08-27 14:23:40 +08:00
starcells 4ff6470cc6 202608271420 2026-08-27 14:20:47 +08:00
starcells 7a55472569 202608271413 2026-08-27 14:14:01 +08:00
starcells f65b46a91a 202608271345 2026-08-27 13:45:46 +08:00
starcells c41f0b02ff 202608271338 2026-08-27 13:38:59 +08:00
starcells 0bc249e35a 202608271235 2026-08-27 12:35:20 +08:00
starcells 16cabba2ee added an export for r8asm 2026-08-26 23:07:57 +08:00
starcells baa7873a36 fixed repeated use of node.value 2026-08-26 21:12:22 +08:00
starcells 5914c15fb2 202608261944 2026-08-26 19:44:28 +08:00
starcells 32cc058c6f 202608261940 2026-08-26 19:40:48 +08:00
starcells af249dc285 202608261937 2026-08-26 19:37:44 +08:00
starcells d3cbf6b2e1 standardized all vector<ast_node> to ast_node with type CODEBLOCK 2026-08-26 19:32:14 +08:00
starcells 3122dee186 202608260040 2026-08-26 00:40:28 +08:00
starcells 6f9c07ba8f 202608260036 2026-08-26 00:36:21 +08:00
starcells e6505a95c0 202608260032 2026-08-26 00:32:30 +08:00
starcells c450ab3f45 202608260028 2026-08-26 00:28:08 +08:00
starcells 53cbf0ccc3 202608260022 2026-08-26 00:22:37 +08:00
starcells 18073acd2c 202608260013 2026-08-26 00:13:59 +08:00
starcells 3dbe5cb4aa 202608260006 2026-08-26 00:06:08 +08:00
starcells 47923363a5 202608252351 2026-08-25 23:51:27 +08:00
starcells ef7a8f9d6c 202608252348 2026-08-25 23:48:59 +08:00
starcells 0c6b494f22 202608251836 2026-08-25 18:36:13 +08:00
starcells 4145ce3989 first commit 2026-08-25 18:09:16 +08:00