# GoSub distance test cases

Six minimal programs, each `GoSub sub1` / `Terminate` / filler `x++` statements
/ `sub1: x++ : Return` -- identical shape to `tests/fixtures/19_gosub_return.mbs`,
just with the subroutine pushed progressively farther from the call site so we
can see whether the real Roboteq compiler/firmware handles `GoSub` addressing
differently once the target address stops fitting in a single byte.

| file                          | `sub1` address | total bytes |
|--------------------------------|----------------|-------------|
| gosub_dist_a_near.mbs          | 5              | 12          |
| gosub_dist_b_under256.mbs      | 205            | 212         |
| gosub_dist_c_at255.mbs         | 255 (0xFF)     | 262         |
| gosub_dist_d_at260.mbs         | 260 (0x0104)   | 267         |
| gosub_dist_e_mid.mbs           | 505            | 512         |
| gosub_dist_f_near1024.mbs      | 955            | 962         |

`c` and `d` bracket the interesting boundary: `c`'s subroutine address still
fits in one byte (0xFF), `d`'s doesn't (0x0104) -- if there's an
address-width bug specific to `GoSub` (as opposed to `GoTo`, which our own
codegen tests already confirm works past 256 bytes), it should show up
between these two. `f` stays under the 1024-byte ceiling you mentioned while
still testing a large, page-crossing distance.

Each `*_ours.hex` is what *this* compiler currently produces -- not yet
confirmed against real hardware.

## Workflow

1. Open each `.mbs` in RoborunPlus, compile, export the real `.hex`.
2. Save it back into this folder as `<name>.hex` (e.g. `gosub_dist_a_near.hex`,
   next to its `_ours.hex`).
3. Diff:
   ```
   python tools/hexdiff.py diff tests/gosub_distance/gosub_dist_a_near_ours.hex tests/gosub_distance/gosub_dist_a_near.hex
   ```
   (repeat per file, or ask Claude to run all six once they're in place).
