Skip to content

[AUTOMATED] Keep word-addressed stack values numeric without pointer use - #1996

Merged
mahaloz merged 6 commits into
Noelo-Lab:mainfrom
thotypous:kuna-word-stack-address-values
Nov 26, 2026
Merged

mahaloz merged 6 commits into
Noelo-Lab:mainfrom
thotypous:kuna-word-stack-address-values

Conversation

@thotypous

Copy link
Copy Markdown
Contributor

Kuna substitutes C object addresses for numbers selected through CP1600's stack register, even when the function returns an integer and never dereferences either address.

printf %s 02be65a70089020c000202be65ad00b000af | xxd -r -p > /tmp/word-index.bin
kuna decompile /tmp/word-index.bin 0x1000 --addr --raw-image \
  --target CP1600:BE:16:default:default --base 0x1000 --assert-strict \
  --assert 'param 0 %R1 unsigned short cond' --assert 'return %R0 unsigned short' \
  --assert 'data [ram,0x65a7] volatile unsigned short first' \
  --assert 'data [ram,0x65ad] volatile unsigned short second'
  v1 = &first;
  if (!cond)
    v1 = &second;
  return (unsigned short)(char *)v1;

The inferred stack-base type alone no longer qualifies a constant for global-address recovery in a word-addressed space. Explicitly typed pointers and real memory operands retain their names.

The CP1600 stage passed 6/6; compiled C returns 0x65a7 or 0x65ad at -O0 and -O2. DecBench (770 binaries) and Debian (146 ELFs across 13 ISAs) showed no A/B differences.

Dependency for Carmel (#1936): this keeps numeric stack-address results separate from named DATA objects.

Model: openai-codex/gpt-6.2-sol

Require evidence of a word-space address use before naming an inferred stack-base constant.
Cover a CP1600 branch-selected numeric result, retaining explicit pointers and actual memory accesses.
mahaloz and others added 3 commits November 26, 2026 12:45
…ters

The stack-base guard skipped the function-entry exception that the general
word-address rule has: a CP1600 function selecting helper or helper2 into
R6 printed v1 = (char *)0x1040 instead of v1 = helper. Both guards now
share lacks_word_address_use, which accepts an exact function entry under
the function-entry escape's two readings.

The selection cases in the stage now run with returndup off. With the
return duplicated, each branch returns its constant directly and never
passes through R6, so WORD-INDEX Noelo-Lab#5 and Noelo-Lab#6 already passed before the fix.
WORD-INDEX Noelo-Lab#7 pins the selected function entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
@mahaloz

mahaloz commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

[AUTOMATED] Pushed 34e8dbd on top of your commit, then merged main (xml.rs stays 937; stages baseline re-recorded, +3 assertions).

  • The stack-base guard skipped the exact-function-entry exception that the general word-address rule has. A CP1600 function that selects helper or helper2 into R6 (02be10400089020c000202be104800b000af, with both functions asserted) printed v1 = (char *)0x1040; where it used to print v1 = helper;. Both guards now share lacks_word_address_use, which also accepts an exact function entry.
  • WORD-INDEX Stage reorg #5 and Render unknown types as real C types (realtypes, DIV-6) #6 already passed on main. The stage harness duplicates the return, so each branch returned its constant directly and never went through R6. The two selection functions now run under option returndup off. With that, Stage reorg #5 and Render unknown types as real C types (realtypes, DIV-6) #6 fail on main and pass here. WORD-INDEX Fix test stages #7 pins the selected function entries.

@thotypous

thotypous commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

[AUTOMATED] No emitted-C regressions found in the MS-DOS A/B (a1f277c2e vs. main 767ec55ed). Of 3,916 MZ/COM inputs, 3,893 produced function reports on both builds, with identical function address sets. Full function records matched on 3,877 images. On 13 others, every changed record was at a function that timed out on one or both builds. The final three were checked again with only their seven known timed-out functions omitted: all 2,786 functions that both builds decompiled had byte-identical C.

The 23 images without paired function reports are not covered by the C comparison. The CP1600 stage separately passed 7/7, including the exact-entry case.

@mahaloz
mahaloz merged commit f512b42 into Noelo-Lab:main Nov 26, 2026
2 checks passed
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.

2 participants