# Batch 1 -- minimal-pair reverse-engineering corpus

20 small `.mbs` scripts designed so that diffing specific pairs isolates one
bytecode construct at a time, the same technique that worked on the real
`R0-7A`/`R0-7Y` revision pair (single-character/single-value source changes
-> single-byte bytecode changes).

## What to do with these

For each `NN_name.mbs` file in this folder:

1. Open it in RoborunPlus's MicroBasic script editor (Scripting tab).
2. Click **Build** (not Simulate -- see the warning on `18_goto.mbs` below).
3. Export/save the compiled result as a `.hex` file with the **same base
   name**, in this same folder -- e.g. `02_assign_x0.mbs` -> `02_assign_x0.hex`.

Once all 20 `.hex` files exist next to their `.mbs` sources, they can be fed
through `tools/hexdiff.py diff <a>.hex <b>.hex` per the pairing table below.

**Warning:** `18_goto.mbs` contains an intentional infinite loop (`GoTo top`
with no exit condition). Build and export it, but don't click Simulate/Run on
it -- it won't terminate.

## Pairing table -- what each diff should isolate

| Compare | Isolates |
|---|---|
| `00_baseline` vs `01_dims` | Whether declaring `x`, `y`, `z` changes anything at all (expect: no diff -- confirms `Dim` is still a no-op with these types/count) |
| `02_assign_x0` vs `03_assign_x1` | Literal encoding for values 0 vs 1 |
| `04_assign_x127` vs `05_assign_x128` | The int8/int16 encoding threshold (127 fits signed-8-bit, 128 doesn't) |
| `03_assign_x1` vs `06_assign_xneg1` | How negative values are encoded |
| `06_assign_xneg1` vs `07_assign_xneg129` | Negative-side int8/int16 threshold (-128 is the signed-8-bit floor) |
| `05_assign_x128` vs `08_assign_x_bigint` | Whether very large values (2147483647) get a wider (4-byte?) encoding or reuse the 16-bit form with different semantics |
| `02_assign_x0` vs `09_var_to_var` | Variable-read opcode (`y = x` reads `x`, vs `02` which only ever writes) |
| `10_op_add` vs `11_op_sub` vs `12_op_mul` vs `13_op_div` vs `14_op_mod` | Arithmetic operator opcodes (all five share the identical `x = 5 / y = x` prefix, so the diff is purely the operator byte) |
| `15_if_line_eq` vs `16_if_line_lt` | Relational operator opcode (`=` vs `<`) inside `If ... Then` |
| `16_if_line_lt` vs `17_if_block` | Line-form vs block-form `If` encoding (same condition and same true-branch statement) |
| `18_goto` | Label + `GoTo` encoding, in isolation (no prior corpus example of a label used as a jump target rather than just a program-start marker) |
| `19_gosub_return` | `GoSub`/`Return` encoding, and how it differs from `GoTo` (should show a return-address push/pop the `GoTo` case doesn't have) |

## After this batch

Once these are analyzed, the next batches will cover: arrays, `While`/`Do`
loops, `For`/`Next` (both styles), compound assignment (`+=` etc.) and
increment/decrement, `Print` with variable/expression arguments, and the
device I/O functions (`GetValue`/`SetConfig`/`SetCommand`/`GetConfig`,
timers, math functions). Didn't want to hand over 70+ files in one go before
seeing whether this batch's naming/pairing approach actually works well in
practice.
