[Coco] 6502 to 6809 translation

William Astle lost at l-w.ca
Mon Aug 1 18:40:50 EDT 2011


On 11-08-01 04:12 PM, gene heskett wrote:
> On Monday, August 01, 2011 05:53:39 PM William Astle did opine:
>
>> On 11-08-01 02:57 PM, gene heskett wrote:
>>> On Monday, August 01, 2011 04:56:24 PM Arthur Flexser did opine:
>>>> Wouldn't lda data_addr,y (without the parentheses) do the equivalent?
>>>> Add data_addr to y and load the a register from the address $8020?
>>>>
>>>> Art
>>>
>>> If it doesn't work, what have I been doing for 20+ years?
>>> It works.  What is the problem?
>>
>> Using "lda data_addr,y" will only work if data_addr is the address of
>> the data which is not the case here since data_addr is the address at
>> which the data address is stored.
>
> Humm, but do we not have the "lda [data_addr,y]" ??
>
> Note that the moto book uses [$F000] as an example, but if the symbols and
> register contents are known to the assembler from previous defines, then
> there is nothing to prevent the assembler from filling in the 16 bit
> address within the bra[]ets, and I am pretty sure that I have done that,
> particularly using the [data_addr,pcr] notation, where one has specified
> with an fdb, the address of a register to be read for status.

You're missing a detail in the original question. Let's make the 
following assumptions, codified as source code:

	org $2000
data_addr	fdb $8000

	org $2020
	fdb $8272

	org $4000
	ldy #$20
* sequence 1
	lda [data_addr,y]
* sequence 2
	lda data_addr,y
* sequence 3
	ldd data_addr
	lda d,y
* end options
	org $8020
	fcb $42

	org $8272
	fcb $32

Sequence 1 will result in A containing $32 because it will read the 
address at $2020 and use that as the address to load A from.

Sequence 2 will result in A containing $82 because it will fetch A from 
$2020.

Sequence 3 will result in A containing $42, which is what the original 
6502 instruction would do (assuming it were implemented on the 6809).

Essentially, the 6502 is loading a 16 bit base address from the address 
of data_addr and adding the value in Y to that address to form the 
effective address which is used for loading A. Using 6809 nomenclature, 
that would be "LDA [data_addr],y", which obviously does not exist. Such 
weird (to us) gyrations are required because the 6502 has no 16 bit 
registers and on the 6502, the address of "data_addr" would have to be 
in the direct page.

>
> Or am I losing my touch?
>
>>>> On Mon, Aug 1, 2011 at 7:02 AM, Phill Harvey-Smith
>>>>
>>>> <afra at aurigae.demon.co.uk>   wrote:
>>>>> Hi All,
>>>>>
>>>>> I'm currently trying to translate some 6502 code to run on the
>>>>> Dragon/CoCo, all is prety easy except for one thing, the 6809
>>>>> doesn't appear to have one of the 6502 indexed modes namely :
>>>>>
>>>>> asume that data_addr contains $8000
>>>>> and y=$20
>>>>>
>>>>>          lda     (data_addr),y
>>>>>
>>>>> which will IIRC take look in data_addr, find $8000 and load a from
>>>>> $800+$20 = $8020.
>>>>>
>>>>> the 6809 has
>>>>>
>>>>>          lda     (data_addr,y)
>>>>>
>>>>> but this will load a from where data_addr+$20 points to, which is
>>>>> not the same thing !
>>>>>
>>>>> So is there an easy way of translating the 6502 code in a couple of
>>>>> 6809 instructions ?
>>>>>
>>>>> Cheers.
>>>>>
>>>>> Phill.
>>>>>
>>>>> --
>>>>> Coco mailing list
>>>>> Coco at maltedmedia.com
>>>>> http://five.pairlist.net/mailman/listinfo/coco
>>>>
>>>> --
>>>> Coco mailing list
>>>> Coco at maltedmedia.com
>>>> http://five.pairlist.net/mailman/listinfo/coco
>>>
>>> Cheers, gene
>>
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> http://five.pairlist.net/mailman/listinfo/coco
>
>
> Cheers, gene




More information about the Coco mailing list