[Coco] 6309 Weirdness ??

Robert Gault robert.gault at worldnet.att.net
Wed May 16 18:08:18 EDT 2007


Darren A. wrote:
>> From: Robert Gault
>> Subject: Re: [Coco] 6309 Weirdness ??
>> <snip>
>>
>> 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.
>>
> -
> Robert,
> 
> On a real 6309, if I use -3 as in your example above, the PC register is 
> set to point back at the second byte of the ADDR instruction which is 
> $30 (LEAX). The third byte ($15) means it executes an LEAX -11,X and 
> then proceeds to the RTS instruction.
> 
> In my experience, when -4 is used, the loop runs forever if interrupts 
> are masked. If interrupts are enabled then the first IRQ, upon RTI, 
> resumes execution at the address preceding the ADDR instruction.
> 
> Darren
> 

Ignoring the fact that my code should have read
  RTS
  END START
and not
  RTS START
the actual results ought to depend on how the assembler generates code. 
Using EDTASM6309 the generated code is
7000 8E FFFD
7003 1A 50
7005 1030 15
7008 39

If ADDR X,PC fills regPC with the address of the next instruction 7008 
and then adds regX=-3 the new value of regPC would be 7005 which is not 
in the middle of an instruction.

I'll grant the possibility that not all 6309s work the same but I'd 
expect Hitachi quality control to make that unlikely. It is much more 
likely that our assemblers are generating different code. What are you 
using and what has actually been generated?



More information about the Coco mailing list