64tass Troubleshooting: Common Errors and Fixes
Overview
This guide covers frequent problems when using 64tass (a 6502/65xx family assembler) and concise fixes to get your builds back on track.
1. “Unknown instruction” or “Illegal opcode”
- Cause: Typo in mnemonic, unsupported CPU mode, or using an instruction not available for the selected CPU.
- Fixes:
- Check spelling of the mnemonic.
- Specify the correct CPU in command line or source (e.g.,
–cpu 65c02) if using extended instructions. - If targeting vanilla 6502, replace unsupported opcodes with equivalent sequences.
2. “Addressing mode not supported” or wrong operand size
- Cause: Using an addressing mode that doesn’t match the operand or CPU (e.g., trying absolute,X with a label outside zero page).
- Fixes:
- Confirm operand fits the chosen mode (zero page vs absolute).
- Force a mode explicitly using size suffixes or expressions (e.g., use
LDA \(00</code> for zero page or <code class="qlv4I7skMF6Meluz0u8c wZ4JdaHxSAhGy1HoNVja _dJ357tkKXSh_Sup5xdW">LDA \)0100for absolute). - Switch CPU mode if you need a particular addressing feature.
3. “Expression too large” / constant overflow
- Cause: Immediate or branch displacement exceeds allowed range.
- Fixes:
- For branches, ensure target is within -128..+127 bytes; use a JMP (long branch) if out of range.
- For immediate operands, ensure values fit 8-bit or 16-bit constraints; mask or split larger values (
.BYTE value & $FF). - Use labels and compute offsets carefully; evaluate expressions with parentheses.
4. “Undefined symbol” or forward-reference errors
- Cause: Label referenced before it’s defined or missing symbol due to conditional assembly.
- Fixes:
- Ensure labels are defined; move or add the label before use where possible.
- Use
=or.equto define constants before use. - If conditional assembly hides definitions, check
.if/.elseblocks and define fallback values.
5. “Duplicate symbol” or multiple definitions
- Cause: Same label or symbol defined more than once (across included files or multiple passes).
- Fixes:
- Rename conflicting symbols or convert duplicates to local labels (use numeric local labels or scope mechanisms).
- Use
.global/.exportintentionally and avoid exporting internal labels. - Check included files and conditional blocks for accidental redefinitions.
6. Linker-related errors (wrong addresses, overlaps)
- Cause: ORG directives, segments, or linker settings place code/data where they overlap or conflict with ROM/RAM layout.
- Fixes:
- Verify
.orgvalues and segment assignments match your target memory map. - Use labels and
*(current location) carefully; inspect generated listing to confirm placements.
- Verify
Leave a Reply