[Coco] Basic09 6309 version

William Astle lost at l-w.ca
Wed May 24 23:52:50 EDT 2017


On 2017-05-24 08:49 PM, Walter Zambotti wrote:
> It appears that the 6309 version of basic 09 has a few bugs in using functions expecting integer parameters.
> 
> Namely the MOD and INT functions are not working.
> 
> There may possibly be more functions similar to this that are not working.
> 
> Does anyone know how the 6809 version was modified to become the 6309?
> 
> Also what enhancements are provided in the 6309 version?
> 
> Is the source available so we can make further changes?
> 
> It's time to review the changes and try and fix the 6309 version or just stop using it in preference for the 6809 version.
> 
> Ok people what do we know?

I don't think we know as much as we think we do at this point. All the 
tests reported so far are using VCC unless I missed something in my 
mailbox, and the wording of one of the reports suggests it might have 
been a bug in VCC. (I'd quote the relevant report if I could find it.)

For the record, I looked at the 6309 integer MOD code in the nitros9 
repo. MOD calls the main integer division routine. The code there is 
correct. It uses the following sequence:

	LDW 7,Y ; load dividend (at 7,Y)
	SEXW	; sign extend to 32 bits
	DIVQ 1,Y ; do the division (16 bit divisor at 1,Y)

That leaves the quotient in W and the remainder in D. There are some 
additional instructions that save the result and fix up the sign of the 
remainder which are all correct as well.

My guess is the VCC isn't implementing DIVQ correctly, probably by not 
providing the remainder unless regular integer division is also failing.

This needs to be tested on a real 6309 to see if the same behaviour 
exists there in order to rule out a bug in the 6309 implementation in 
VCC. Even a test on MAME would be instructive.


More information about the Coco mailing list