Skip to content

CI: check the code GCC and vasm emit (kb:expect) - #32

Merged
WDrijver merged 1 commit into
mainfrom
verify-emitted-code
Nov 8, 2026
Merged

WDrijver merged 1 commit into
mainfrom
verify-emitted-code

Conversation

@WDrijver

@WDrijver WDrijver commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Step 3, part 1: kb:compile blocks can now check what the toolchain emits. They don't only prove that the code compiles.

What it does

  • // kb:expect <text> / kb:expect-not: for C and C++, the text must, or must not, occur in GCC's -S output. For assembly, the text is hex bytes that must, or must not, occur in vasm's -Fbin output.
  • kb:opts <flags>: build the block with other code-generation flags.
  • tools/compile-snippets.sh also writes .asm / .bin for blocks that have checks; tools/check_emitted_code.py checks them (new step in compile-examples).
  • Documented in CONTRIBUTING.md sections 6 and 10, and in toolchain/index.md.

The checks read text and bytes: m68k-amigaos-objdump can't decode 68080 instructions (cmpiw.l comes out as .short 0x4e2f).

First checks (13 expectations, all pass locally with GCC-6.50-Dev)

  • toolchain/pitfalls/float-settings-mismatch.md: -m68080 -m68881 gives fsmul.s; -m68080 alone gives ___mulsf3.
  • toolchain/compiler-variants.md: GCC emits cmpiw.l, addiw.l, dbral, and a move.l #imm instead of moviw.l.
  • toolchain/pitfalls/vasm-68080-encoding-issues.md: add.l b1,d0 → $71F1, tst e6 → $7104 4A46, add.l #imm,En → $7101, out-of-range bra.s → bra.s+ $6049.

Content change

compiler-variants.md: the ACD README lists moviw.l and bcc.s+ among the instructions GCC generates. Neither WDrijver/gcc (gcc-stable, 68080regs) nor the ACD patches have a pattern for them, and GCC-6.50-Dev emits move.l #imm instead. The text now says this (SRC), and a check fails as soon as GCC starts emitting moviw.

Not yet checked (findings for TuKo1982)

vasm-68080-encoding-issues.md says that without -no-opt, vasm emits and/or/sub #imm instead of andi/ori/subi and turns move.l #imm into moveq. With vasm 2.0f from ACD (Mac, 2026-11-08):

  • move.l #5,d0 stays 203C 0000 0005 with any option (default, -no-opt, -opt-speed, -devpac, -phxass).
  • and.l #5,d0 → C0BC and or.l #5,d1 → 82BC, also with -no-opt and -devpac.
  • Without -no-opt, sub.l #500,d2 becomes the 68080 addiw.l #-500,d2 (06C2 FE0C); with -no-opt it becomes 94BC 0000 01F4.

Not changed here: these claims are (M) and from TuKo, so he decides.

Knowledge base files relied on

  • toolchain/pitfalls/float-settings-mismatch.md, toolchain/pitfalls/vasm-68080-encoding-issues.md, toolchain/compiler-variants.md, toolchain/pitfalls/gcc-dbra-address-register-loop.md
  • core/cpu-68080/prm/integer/bra-s-plus.md, core/cpu-68080/prm/integer/moviw.md, core/cpu-68080/branches-and-prediction.md

🤖 Generated with Claude Code

kb:compile blocks can now carry kb:expect / kb:expect-not lines (text in
GCC's -S output, or hex bytes in vasm's -Fbin output) and kb:opts (other
code-generation flags). tools/check_emitted_code.py runs after compiling
in the compile-examples job.

First checks: hard vs soft float (float-settings-mismatch), the 68080
instructions GCC emits (compiler-variants), four vasm encodings
(vasm-68080-encoding-issues).

compiler-variants: GCC has patterns for cmpiw.l, addiw.l and dbra.l only;
moviw.l and bcc.s+ from the ACD README are not in the GCC source or the
ACD patches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant