mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 02:56:36 -04:00
7c40d33db3
Phase 1a (boot slice): 30 instructions at 0xBFC00000, compiles clean. Phase 1b (instruction coverage): 54 opcodes implemented in strict_translator, 44,629 walker-reachable instructions covered, 0 missing. Phase 1c (function discovery): 76 functions from 2 seeds, 2,988 instructions, 199 call edges, 27 indirect jumps. All validated through StrictTranslator. Phase 1d (indirect control flow): 27 sites classified — 21 A0/B0/C0 dispatch stubs, 4 computed calls, 2 computed tail calls. Ghidra cross-referenced with 0 disagreements. Phase 1e (relocation): ROM-to-RAM copy at FUN_bfc00420 proven with both Ghidra (static) and DuckStation (runtime). 69 address aliases, 68/69 function entries match byte-for-byte in RAM. Normalization rule documented. Includes PRINCIPLES.md and DEBUG.md adapted from recomp-template. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
#!/usr/bin/env python
|
|
# Compute 10 ** exp with exp in the range [min_exponent, max_exponent] and print
|
|
# normalized (with most-significant bit equal to 1) significands in hexadecimal.
|
|
|
|
from __future__ import print_function
|
|
|
|
min_exponent = -348
|
|
max_exponent = 340
|
|
step = 8
|
|
significand_size = 64
|
|
exp_offset = 2000
|
|
|
|
class fp:
|
|
pass
|
|
|
|
powers = []
|
|
for i, exp in enumerate(range(min_exponent, max_exponent + 1, step)):
|
|
result = fp()
|
|
n = 10 ** exp if exp >= 0 else 2 ** exp_offset / 10 ** -exp
|
|
k = significand_size + 1
|
|
# Convert to binary and round.
|
|
binary = '{:b}'.format(n)
|
|
result.f = (int('{:0<{}}'.format(binary[:k], k), 2) + 1) / 2
|
|
result.e = len(binary) - (exp_offset if exp < 0 else 0) - significand_size
|
|
powers.append(result)
|
|
# Sanity check.
|
|
exp_offset10 = 400
|
|
actual = result.f * 10 ** exp_offset10
|
|
if result.e > 0:
|
|
actual *= 2 ** result.e
|
|
else:
|
|
for j in range(-result.e):
|
|
actual /= 2
|
|
expected = 10 ** (exp_offset10 + exp)
|
|
precision = len('{}'.format(expected)) - len('{}'.format(actual - expected))
|
|
if precision < 19:
|
|
print('low precision:', precision)
|
|
exit(1)
|
|
|
|
print('Significands:', end='')
|
|
for i, fp in enumerate(powers):
|
|
if i % 3 == 0:
|
|
print(end='\n ')
|
|
print(' {:0<#16x}'.format(fp.f, ), end=',')
|
|
|
|
print('\n\nExponents:', end='')
|
|
for i, fp in enumerate(powers):
|
|
if i % 11 == 0:
|
|
print(end='\n ')
|
|
print(' {:5}'.format(fp.e), end=',')
|
|
|
|
print('\n\nMax exponent difference:',
|
|
max([x.e - powers[i - 1].e for i, x in enumerate(powers)][1:]))
|