* * * * *

                   A quirk of the Motorola 6809 assemblers

I just learned an interesting bit of trivia about 6809 assembly language on a
Discord server today. When Motorola designed the 6809 assembler, they made a
distinction between the use of n,PC and n,PCR in the indexing mode. Both of
those make a reference based off the PC register, but in assembly language
they defined, using n,PC means use the literal value of n as the distance,
whereas n,PCR means generate the distance between n and the current value of
the PC register.

I never knew that.

I just looked and all the materials I had on the 6809 use the n,PCR method
everywhere, yet when I wrote my assembler [1], I only support n,PC and it
always calculates the distance. I think I forgot that it should have been
n,PCR because on the 68000 (which I also programmed, and was also made by
Motorola) it always used n,PC.

And I don't think I'll change my assembler as there does exist a method to
use an arbitrary value of n as a distance: LDA (*+3)+n,PC. The asterisk
evaluates to the address of the current instruction, and by adding 3 you get
the address of the next instruction, which in the PC-relative addressing
mode, is a distance of 0. Then n will be the actual offset used in the
instruction. Yes, it's a bit convoluted, but it's a way to get how Motorola
originally defined n,PC.

And apparently, Motorola defined it that way to make up for less intelligent
assemblers back in the day due to memory constraints. We are long past those
days.

[1] https://github.com/spc476/a09

Email author at [email protected]