whartung wrote:
Simply, will a 6502 assembly language program assemble properly in a 65816 assembler, especially if the LONGI and LONGA attributes are defaulted to 8 bit.
Yes.
Incidentally, the LONGA, LONGI, etc., pseudo-ops are specific to certain assemblers and merely tell the assembler to generate an 8 or 16 bit immediate mode operand. These pseudo-ops do not tell the '816 which register sizes to use—that is determined by how the
m and
x bits in the status register are conditioned. The REP and SEP instructions are used to condition
m and
x, usually within some macros, as Garth mentioned.
Quote:
The "downside" of assembling a 6502 program in a 65816 assembler is simply that if you accidentally use a 65816 feature (different addressing mode, for example), then the assembler wouldn't complain, and it would assemble an inappropriate code.
Most assemblers that support the '816 have a pseudo-op that defines the target MPU. If that is the case and the assembler is told it is assembling for a 6502 or 65C02, 65C816-specific mnemonics and/or addressing modes will produce an assembly-time error.
BigEd wrote:
Edit: I suppose with the '816's extra instructions, some words which were, say, previously legal labels, variables or macro names might now match mnemonics and become illegal. For example if you had a macro called JML that might be an error.
That seems to vary from one assembler to another. I've encountered a few assemblers that consider anything that starts in column one to be a label or symbol, even if it is a legal mnemonic. Hence:
Code:
LDA LDA #$12
would assemble without error. Of course, that is probably something best avoided for clarity's sake.
Also, there are a few assemblers that allow macro names to be the same as mnemonics and thus will allow a macro to replace the mnemonic in instructions. The Commodore HCD65 assembler had this capability, which allowed me to assemble standard 6502 instructions with 65C02-specific addressing modes (e.g,
BIT #).