Skip to content

t27a: mnemonic table and strict decoder for the 47 TRI-27 opcodes (sieve, T736) #6516

Closed

Description

@gHashTag

Boundary

  • specs/isa/t27a_mnemonics.t27 (new file; nothing else)

User Scenarios

  • A t27a assembler author needs one place that maps the 47 TRI-27 mnemonics' table index to the opcode byte and back, so the assembler and the disassembler read the same table (epic EPIC: golden reference language -- the compiler sieve (TNF-style theorems), and t27 passes it #6488, theorems T735-T736 in specs/compiler/theory/isa_round_trip.t27).
  • A disassembler user must be told when a byte is not an opcode. Today decode_opcode in specs/isa/ternary_encoding.t27 maps the 209 undefined bytes to NOP, so garbage reads as NOP.

Requirements

  • New module T27aMnemonics in specs/isa/t27a_mnemonics.t27, with use isa::ternary_encoding;.
  • pub fn opcode_at(i: u32) -> u32 gives the opcode byte of table index 0..46 in the order of OPCODE_VALUES, and 256 for any other index. Write it as if chains, not array indexing.
  • pub fn index_of(op: u32) -> u32 is its inverse, and gives 47 for an undefined byte.
  • pub fn strict_decode(byte: u32) -> u32 returns the byte for a defined opcode and 256 (invalid) otherwise.
  • Tests that call these functions at run time:
    • index_of(opcode_at(i)) == i for every i in 0..46;
    • exactly 47 bytes in 0..255 have strict_decode(b) != 256;
    • exactly 209 bytes are rejected;
    • a negative control showing decode_opcode maps byte 1 to NOP while strict_decode(1) == 256.
  • Do not copy any function body from specs/isa/ternary_encoding.t27 or specs/compiler/theory/isa_round_trip.t27. The dupe ratchet rejects copied bodies; call them through use instead.
  • Lines start with ; for prose (never a bare ;), ASCII only, English identifiers.
  • The PR contains only .t27 and t27c-generated files (owner hard rule 2026-10-05).
  • The PR says Closes #<this issue> and Refs #6488.

Success Criteria

  • t27c typecheck specs/isa/t27a_mnemonics.t27 prints Typecheck OK (0 errors.
  • t27c gen-c specs/isa/t27a_mnemonics.t27 > /dev/null exits 0.
  • grep -c '^test ' specs/isa/t27a_mnemonics.t27 prints 3 or more.
  • grep -c 'strict_decode' specs/isa/t27a_mnemonics.t27 prints 3 or more.
  • git diff --name-only origin/master...HEAD lists only specs/isa/t27a_mnemonics.t27.

Activity

  1. added a commit that references this issue on Oct 6, 2026
    9ca5fff
  2. added a commit that references this issue on Oct 6, 2026
    345dcbb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/highMust fix before next milestone

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions