[Coco] ASM question: LDA ,X

William Astle lost at l-w.ca
Wed Jan 23 16:00:03 EST 2019


You can't combine a constant offset with post-increment or 
pre-decrement. This is not a limitation of the assemblers, either. The 
CPU just doesn't have a way to do it.

The reason the comma is required is to provide an unambiguous syntax 
that allows the assembler to identify that the indexing modes are being 
used. Speaking as someone who has written a 6809 assembler, having that 
clue is a lot more helpful than you might expect. It also makes it 
easier for a human to recognize that a non-constant address is in use 
when reading the source.

Also, as an aside, the "0,x" and ",x" operands actually have different 
encodings in the final result. They have the same result, but the ",x" 
one is faster. Many assemblers will optimize "0,x" to be ",x", but 
that's not something you can rely on.

On 2019-01-23 1:45 p.m., Salvador Garcia via Coco wrote:
> Hi all,
> I have been looking at assembly language and have come across instructions such as:
> LDA , X
> LDA , X+
> I've seen LDA , X also expressed as LDA 0, X which means that an explicit offset of 0 is added to the X register. I assume that I can also do this with LDA , X+, that is, LDA 0, X+. What I can't seem to understand is why the ASM syntax requires that coma when there isn't any offset specified. For example, is something like this valid?
> LDA 20, X+
> Does this add 20 to X to get the data, then increments X? I have not seen this type of syntax in the docs that I am looking at. As always, thanks! Salvador
> 
> 
> 



More information about the Coco mailing list