Skip to content

Added arithmetic operators, comparisons for all types#6

Merged
jackwthake merged 10 commits into
mainfrom
feat/code-generation
Jun 24, 2026
Merged

Added arithmetic operators, comparisons for all types#6
jackwthake merged 10 commits into
mainfrom
feat/code-generation

Conversation

@jackwthake

@jackwthake jackwthake commented Jun 24, 2026

Copy link
Copy Markdown
Owner
  • Codegen safety net - unhandled TAC ops now fail loudly instead of silently producing wrong binaries
  • Fixed global/ZP bug class - ++/-- on globals and comparison RHS operands now correctly use absolute addressing instead of stale zero-page scratch slots
  • Arithmetic for all integer types - TAC_ADD, TAC_SUB, TAC_NEG for u8/i8/u16/i16 with width-aware multi-byte carry/borrow propagation
  • u16 comparisons - high-byte-first comparison pattern replaces the old byte-0-only COMPARE_OP macro
  • Signed comparisons - i8/i16 ordering via the N⊕V pattern (SEC; SBC; BVC +2; EOR #$80; BMI)
  • 15 new emulator tests covering all new codegen features

Bootstrap emu tests switched from analyzer_basic.c02 (which uses TAC_ADD,
TAC_CALL, TAC_FIELD_STORE) to the minimal emu_store_const.c02.
Emu tests: emu_inc_global (global++, assert 42), emu_cmp_global (compare
local against global, assert branch takes else-body).
Emu test: emu_neg_u8 (double negate: -(-42) = 42).
Emu tests: add_u16 (300+200=500), sub_u16 (1000-500=500), add_i8 (-5+47=42),
add_i16 (-300+800=500).
Emu tests: cmp_u16_lt (255<256), cmp_u16_eq (500==500), cmp_u16_gt (1000>255).
Emu tests: cmp_i8_lt (-5<3), cmp_i8_gt (3>-5), cmp_i8_neg (-10<-3),
cmp_i16_signed (-300<300).
@jackwthake jackwthake added the enhancement New feature or request label Jun 24, 2026
@jackwthake jackwthake merged commit 6a9071f into main Jun 24, 2026
6 checks passed
@jackwthake jackwthake deleted the feat/code-generation branch June 24, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant