[Coco] 6309 Weirdness ??
Robert Gault
robert.gault at worldnet.att.net
Wed May 16 05:25:46 EDT 2007
Darren A. wrote:
>> From: Robert Gault
>> Subject: Re: [Coco] 6309 Weirdness ??
>> Date: Tue, 15 May 2007 22:04:53 -0400
>>
>> <snip>
>>
>> My tests indicate that you are misinterpreting your results.
>>
>> When I run the program
>> org $7000
>> start ldx #$1234
>> $7003 addr pc,x
>> $7006 swi
>> end
>> the result is that regX contains $1234+$7003+3=$823A.
>> <snip>
>> Your example LDX #-4 ADDR X,PC will lead to disaster. Using -3, the
>> program should loop indefinitely at the addr x,pc instruction. But
>> with -4, the program will jump into the middle of the ldx #-4
>> instruction. The result in most cases will be an illegal instruction
>> resulting in the 6309 jumping to a special trap which in most cases
>> will not have a vector installed.
>>
>> --
>
> -
>
> Robert,
>
> Did you run your test on real 6309 hardware or with an emulator? When I
> run the example you provided:
>
> ORG $7000
> 7000 LDX #$1234
> 7003 ADDR PC,X
>
> ..I get the same results you did if I run it on MESS (X = $823A), but I
> get a different result (X = $823B) when I run it on real hardware. This
> indicates to me that the CPU is calculating it as ($1234 + $7003 + 4).
>
> Thus the example I gave:
>
> LDX #-4
> ADDR X,PC
>
> ...will, as you say, lead to disaster if run on MESS, but works on a
> real 6309 (as long as interrupts are masked). That was the point of my
> post; that the real CPU isn't behaving the way I was led to believe. I
> even tried it with two different processors (a 63B09E and a 63C09E) just
> to see if I had a defective one.
>
> Darren
>
I had tried first on MESS. I just tried the code on a real Coco3 but
still don't get your results although there is a problem.
ORG $7000
7000 LDX #$1234
7003 ADDR X,PC
7006 SWI
results in regPC=$823A which is what it should be but still unexpected.
I ran the test in the Debug module of EDTASM and would have expected the
code to jump to $823A which is RORB and then attempt $823B which is an
illegal instruction. That was what happened with MESS. However, on a
real Coco EDTASM issued a BRK @ 823A with regPC=$823A even though there
was no breakpoint set there.
ORG $7000
7000 LDX #$1234
7003 ADDR PC,X
7006 SWI
results in regX=$823B and regPC=$7006. Here the addition is wrong even
though regPC stepped through the code correctly.
The code
LDX #-3
ADDR X,PC
when run from EDTASM with the G (go command) works correctly but stepped
through with "," results in CAN'T CONTINUE regardless of the value in regX.
To remove any effects from EDTASM the following code was assembled
ORG $7000
START LDX #-3
ORCC #$50
ADDR X,PC
RTS START
This when executed, immediately came back to the Basic prompt OK. Same
thing happened with LDX #-4. This opcode ADDR X,PC seems to have been
ignored. Change the RTS to SWI with the code run from Basic caused a
system crash. This seems to comfirm that ADDR X,PC was skipped as Basic
does not like SWI in this context.
More information about the Coco
mailing list