def fix_pc_references(s):
    """Translate references to the current program counter from ca65 to ASM6.

ca65 uses * for PC; ASM6 uses $.
Only references at the start or end of an expression or of a
parenthesized subexpression get translated.  But that should be
enough for our use case, as the source code can use (*) to produce
($) in the translation.
"""
    if s.startswith('*'):
        s = '$' + s[1:]
    if s.endswith('*'):
        s = '$' + s[1:]
    return s.replace('(*', '($').replace('*)', '$)')