6809 experiments

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

6809 experiments

Postby dominicbeesley » Mon Mar 13, 2017 2:54 pm

I've been inspired recently to have a look at the 6809/6309 processors after finally getting my hands on a Matchbox CoPro. One thing has led to another and I've started a few projects. I'm not sure how much interest there will be in my hardware but I suspect the

port NoICE debugger to 2nd proc
===========================
There is an excellent hardware debugger which connects to the host via a serial cable. This has been invaluable in porting BBC Basic
So far this only works with a real BBC and the 6809 as a 2nd processor, I aim to port it to my 6809 board (below) when I've got its serial port working.

port BBC BASIC to the 6809
======================
This is at a stage where basic parsing/listing/running/integer vars are working, repeat,until,procs,floating point (and lots of other stuff) is not
I aim to make this relocatable and at some point get it to run on Flex as well as the co processor

port MOS to 6809
==============
make a version of the MOS that can work with a 6809 as the main processor - this to support my board below but in time may allow a BBC B to have its 6502 popped and a 6809 put in its place...maybe?

A 6809 beeb
==========
This came about after buying a job-lot of random 6809ish chips, this included some 63c09s and some support chips I got giddy and built a computer from scratch on my desk using breadboards and some of the chips (6309, 6845, 27c512, 512k SRAM), Max II CPLD

20170209_110219-s.jpg

20170210_004831-s.jpg


This got going surprisingly quickly and was all great fun until my Max7320 CPLD decided to commit suicide - I'm still not sure what happened but after a reprogram it got VERY hot and died. I checked the program and it was only a minor tweak so not sure what happened. I then switched to using an EPM240 board - these are cheap and plentiful but a bit of a pain because they run at 3.3V and don't like 5V up em, so next job I knocked up some level converters

20170209_113922-s.jpg


This started to grow and become increasingly erratic as I added more and more ratsnest changes so I bit the bullet and decided I'd have to make a PCB. So, I decided it was time to have a bash at sending one for fabrication instead of messing trying to do it myself. I sent the board off to PCBWay in China and apart from a couple of mistakes (forgetting to bring the clock signal out to my "bus" connectors and getting the RGB connector 180 degrees rotated) it has worked...well after going over most of the pins with a soldering iron twice due to my rushed soldering.

20170306_123153-s.jpg


The board sits on risers above the EPM240 dev board which does some glue logic and video ULA duty. The yellow board is my bodge to rotate the RGB din connector.

20170313_125159-s.jpg

20170313_125153-s.jpg

20170313_124203-s.jpg

20170313_124140-s.jpg

20170313_124133-s.jpg


I'm a bit stalled now, I got a serial UART (16550) chip from Hong Kong and can't get it to work - I'm not sure if that is me being rubbish or the chip being a fake. I'm waiting for a replacement from Farnell. I'd like to get the NoICE thing working with the real board then I can get piled in to developing a MOS for the thing.

I must have spent a good few hundred hours on this, it's been great fun!

D

User avatar
hoglet
Posts: 6634
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: 6809 experiments

Postby hoglet » Mon Mar 13, 2017 3:11 pm

Looks like some great work here. Thanks for sharing some pictures.

User avatar
BigEd
Posts: 1501
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: 6809 experiments

Postby BigEd » Mon Mar 13, 2017 3:43 pm

Very interesting projects! The 6309 is held up as the most excellent 8 bit CPU.

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: 6809 experiments

Postby roland » Mon Mar 13, 2017 11:04 pm

An Atom might be a good start to write your own mos. The Atom is a simple machine and it's also very well documented. In fact, back in the 80's some people were actualy replacing the 6502 by a 6809 but they never published their software.

Please keep us informed about your projects.
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
jgharston
Posts: 2764
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: 6809 experiments

Postby jgharston » Tue Mar 14, 2017 2:22 am

dominicbeesley wrote:port BBC BASIC to the 6809
======================
This is at a stage where basic parsing/listing/running/integer vars are working, repeat,until,procs,floating point (and lots of other stuff) is not I aim to make this relocatable and at some point get it to run on Flex as well as the co processor

Cool. I'm updating the mdfs.net/bbcbasic main page, so I'll add a link the 6809 version.

dominicbeesley wrote:I must have spent a good few hundred hours on this, it's been great fun!

Definitely is. I've probably spent hundreds of hours writing PDP11 BASIC and it's just lacking transendentals now (SIN, COS, EXP, etc.). The natural complement to writing a kernel is to write a programming language you can interact with it for it.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

Prime
Posts: 2348
Joined: Sun May 31, 2009 11:52 pm

Re: 6809 experiments

Postby Prime » Tue Mar 14, 2017 9:28 am

roland wrote:An Atom might be a good start to write your own mos. The Atom is a simple machine and it's also very well documented. In fact, back in the 80's some people were actualy replacing the 6502 by a 6809 but they never published their software.

Please keep us informed about your projects.


It also has a 6847 as it's video chip, which already has 6809 routines available to manipulate in the Dragon / CoCo roms, which could maybe be lifted and used. Hummm, porting Dragon BASIC to the Atom....that's probably doable :)

Cheers.

Phill.

dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

Re: 6809 experiments

Postby dominicbeesley » Tue Mar 14, 2017 10:37 am

Thanks all for the kind comments

I got the serial port kind of working last night (I'd misunderstood the complementary WR/WR signals and the reset line for the 16550 is VERY fusy picking up the slightest of noise.) so when my connectors come from Farnell, hopefully today, I should have a full dev system.

I'm not quite sure I get the point about the Atom.

I'll try and gather all the code into a coherent bundle at some point and put it on a site like GitHub but I hate doing all the boring admin...it's like being at work. JGH, I can send you a copy of the BASIC if you'd like (PM me your email) - it's nowhere near ready for release yet though.

I changed the palette too to be a bit less random (this is mode 1 but with an enhanced 16x16x16 palette) here it is doing a serial loop-back test.
20170314_102503-s.jpg

D

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: 6809 experiments

Postby roland » Wed Mar 15, 2017 7:42 pm

dominicbeesley wrote:I'm not quite sure I get the point about the Atom.


Long time ago somebodyat the Dutch Atom User Group replaced the 6502 of the Atom by a 6809 (http://acornatom.nl/atom_nieuws/1987/nr5/19875030.htm) and he managed to get Flex running. If you want to do the same with a BBC micro and write your own MOS you could start in the Atom because its hardware is not that sophisticated like the BBC. For example, for printing characters you don't need to initialize video controllers, just start writing to the video memory. And if you have a working base on the Atom, you can start to extend it to the BBC.

prime wrote:It also has a 6847 as it's video chip, which already has 6809 routines available to manipulate in the Dragon / CoCo roms, which could maybe be lifted and used. Hummm, porting Dragon BASIC to the Atom....that's probably doable :)


In an Atom2k15 you can also redesign the CPLD's to match the Dragon's memory map.
256K + 6502 Inside
MAN WOMAN :shock:

dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

Re: 6809 experiments

Postby dominicbeesley » Thu Mar 16, 2017 10:21 am

Thanks Roland,

That makes sense, however I'm enjoying designing the hardware. D

I've now got a serial port working so debugging will be easier, I will next make the serial port into a plug-in board so its more reliable and takes up less space. Then I need to spend some time tidying up my VHDL to try get my "ULA" to do more than 8 colours...

D

dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

Re: 6809 experiments

Postby dominicbeesley » Sat Apr 15, 2017 5:13 pm

A few updates on the heavy going process.

I got a serial card made up as a PCB and have started porting the MOS from 6502 to 6809...this proved quite heavy going but I've now managed to hack together the best part of the VDU routines (no graphics yet though). I'm not sure what I'll attack next, I may start on the system VIA and keyboard next which will probably need a new PCB making up. I've made the top C000-FFFF (minus FRED,JIM,SHEILA) into a sideways ROM/RAM which allows me to load the new MOS to RAM and then step through it with the NoICE debugger - I'd not have got this far this quickly without it.

Anyway I think I'll cleanse my palette with a bit of boozing and Land Rover gearbox rebuilding for the rest of the weekend. It will give me time to think about whether to go with JGH's OSBYTE API (user registers A,X,Y as on beeb on entry and collate X,Y into X on exit) or to use B in some way...I suspect I'll take the path of least resistance and go with JGH!

D
Attachments
20170415_180214-s.jpg
Boot to welcome message, no ROMS to show yet
20170411_141101-s.jpg
The serial card

dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

Re: 6809 experiments

Postby dominicbeesley » Tue May 23, 2017 11:59 am

Some progress, I'm hoping to have a working MOS, BASIC and an AcornSoft game (snapper?) working by next year and a full-size motherboard but I'm not sure what hardware to support probably:
- discs
- 1Mhz bus
- printer
- user port
- RGB, composite B&W, no UHF?
- no ADC
- no SPEECH
- no ROM cartridges
- SWRAM slots + large EEPROM/Flash for MOS, BASIC, DFS

Not sure what filing systems but I'll probably hack something like turbo/super/whatever/MMC together and maybe ADFS+IDE?

So far, BASIC is no further on than a couple of months ago, I've been concentrating on a SYSVIA/USERVIA+76489 board and getting sound and keyboard working.

Keyboard routines are nearly there but not fully tested, most stuff works but there are some niggles (caps lock doesn't work until after a key has been pressed). I'm currently hacking sound together and then I'm going to plough through the OSBYTE routines. At that point I'll be ready to go back and have a look at the sideways RAM/ROM routines and decide how to go with those. So far I've kept the memory map true to the original model B and started with OS1.20

D

I really need to tidy my desk and do some paying work...
Attachments
20170523_121145-s.jpg
20170523_121123-s.jpg

User avatar
tricky
Posts: 1924
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: 6809 experiments

Postby tricky » Tue May 23, 2017 2:37 pm

I'm a bit late to this thread, but I was looking at some 6809 stuff a while back and found a static code converter from 6502 to 6809 and a 6809 simulator written in 6502. I can't find them now and am wondering if I imagined them!
6809 dim was from a magazine article from the 80s and the static code converter was fairly recent.
It is probably more work in the long run, but maybe automatically converting the 6502 and then optimising/replacing chunk but chunk would get something running sooner.

dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

Re: 6809 experiments

Postby dominicbeesley » Tue May 23, 2017 3:54 pm

Hi Tricky,

A very good point, I thought about that too but I came to the conclusion that, for the MOS ROM at least:
a) it would be inefficient, there's quit a lot of things in the MOS ROM done to make things quicker on the 6502 that are counter productive on the 6809, i.e. storing lists of addresses as two LO/HI byte tables
b) the generated code would probably be more difficult to understand in order to optimise than the plain 6502 (for which copious notes are available i.e. my code has JGH's comments and much of the Micronet dissambly notes)
c) I'd not learn as much, there's a lot I've learnt about the BBC that I didn't know

For BASIC I started out to do more of a complete rewrite rather than a straight port...it's taking a long time but I'm still enjoying it and learning as I go.

Having said all that my 6809 code is probably not the most efficient, quite often a complete rewrite of a system would be best in order to better use the 6809's features. For now I'm just going one step at a time. The lack of a post indexed indirect addressing mode is a bore as it is used a lot by the MOS in the VDU routines. Also, I stupidly didn't realise that when an accumulator is used as an offset to X or Y (which I've done a lot) it works as a 2's complement whereas addr,X in 6502 is unsigned. That led to a lot of head scratching until I worked it out! Also, I've used the Y register quite a bit but not the U register which is probably not the best way to approach things...

I'm half tempted to go back and start again and target the 6309 rather than the 6809 but not sure. The 6309 would do a lot of things much better!

I'd be interested on looking at the converter for maybe helping quickly port DFS and some games though!

D

User avatar
Elminster
Posts: 1632
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK

Re: 6809 experiments

Postby Elminster » Tue May 23, 2017 5:03 pm

I missed the whole 6309/6809 so just wondering what the advantages are over a 6502 based Beeb. I assume more addressable memory.

Very impressive though, which I had either the skills, the time, or both to tackle a project like that.

User avatar
tricky
Posts: 1924
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: 6809 experiments

Postby tricky » Tue May 23, 2017 6:58 pm

Just thought I'd mention them, even if I can't find them now!

My 6809 memories are few and distant, but I seem to remember that it has a kind of offset register, which makes relocatable code quite easy to write.
Doesn't help much with 64K, but when it is easier to address more, its probably very useful, especially for drivers.

dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

Re: 6809 experiments

Postby dominicbeesley » Wed May 24, 2017 8:47 am

It has some very nice features, it's kind of like a beefed up 6502 in some ways, it feels and look similar but has some extras
two 8 bit accumulators
two 16 bit index registers, these work in a slightly different way to the 6502 but similar things can be achieved
two 16 bit stack pointers, these can also be used as index registers
auto increment indexed modes
8x8 bit multiply in 11 cycles!
Direct page - this is 256 bytes a bit like 0 page in 6502 land but you can relocate it by setting a register
Relocatable code is facilitated by there being a program counter relative mode to load addresses into X/Y/S/U
long branch and branch subrountine (relatives of JMP and JSR)

You can't access more than 64k easily (unlike the 65816) which is the only real drawback. I have to say I like it, it feels as simple as 6502 but slightly more "grown up" in the way the stack works. On the current hardware I've just got simple banking to allow for very simple sideways ROM/RAM type behaviour and shadowing of the screen. Unfortunately

If my newbie coding is anything to go by I'd say code density is slightly better and speed a lot better on anything involving 16bit or 32bit numbers, I got some BASIC stuff going about 100% faster - though that was against BeebEm which I don't think is 100% accurate.

The 6309 is it's later cousin, Hitachi licenced the 6809 and found that they had a lot of room left on the die and added a LOT of extras but then decided not to tell anyone - I suspect due to Motorola not being too happy about them extending it. In 6309 native mode there are more registers and lots of extra instructions - not all of which are that useful in terms of speed. A lot of normal instructions use fewer cycles. Most stuff is 100% compatible though there are some slight differences around interrupt routines as they have to push more stuff on the stack to save the extra registers.

I found some of the articles on 6502 to 6809 translation yesterday and had a quick read - it looks like the code density would be a killer for the ROM stuff as space is tight, if anything remotely automatic is to be done a lot of extra code needs to be inserted to emulate the differences in the flags registers, even the single byte txa turns into 6 or so instructions...might still be worth considering for simpler games though.

D

Zarchos
Posts: 2355
Joined: Sun May 19, 2013 8:19 am
Location: FRANCE

Re: 6809 experiments

Postby Zarchos » Wed May 24, 2017 8:58 am

I think I read for the Dragon there are some specific games or apps if this 6309 processor is used.

User avatar
Elminster
Posts: 1632
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK

Re: 6809 experiments

Postby Elminster » Wed May 24, 2017 9:01 am

@dominicbeesley.

Great response thanks.

And I hadnt twigged that the 6309 was newer, assumed (logically I guess) it was a before the 6809.

User avatar
BigEd
Posts: 1501
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: 6809 experiments

Postby BigEd » Wed May 24, 2017 9:48 am

dominicbeesley wrote:... code density is slightly better and speed a lot better on anything involving 16bit or 32bit numbers, I got some BASIC stuff going about 100% faster - though that was against BeebEm which I don't think is 100% accurate.

But accurate enough for this. Very interesting result - with a 4MHz 6809? Look forward to seeing the ClockSp benchmark numbers. (I estimate that the upcoming PiTubeDirect 6809 is at 25-30MHz, but I don't have a well calibrated test.)

dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

Re: 6809 experiments

Postby dominicbeesley » Wed May 24, 2017 9:58 am

Nope, that was at 2MHz, I've still not got round to running at 4MHz yet...

User avatar
BigEd
Posts: 1501
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: 6809 experiments

Postby BigEd » Wed May 24, 2017 10:01 am

Even better!

lezanderson
Posts: 10
Joined: Wed Feb 27, 2013 10:42 am

Re: 6809 experiments

Postby lezanderson » Thu May 25, 2017 11:09 am

Cool project...

It always nice to see something like this as building & making your own homebrew micro is a lost art ! :D

If you need any Free components./..let me know and I'll see what I have

CPUs : Z80,6502,6809,HD64180,Z180,68008,68000,TMS99xx etc

SRAM 128K,64K,32K,etc

EPROMS/EEPROMs, 512K,256K,128K,64K,32K,etc

CPLDs, EPM7128SLC84,EPM7064SLC44,EPM7256 etc

Video Processors, R6545,6845,V99xx,TMS9918 etc

Sound Chips : SN76489,SAA1099,AY-3-89xx,YM2149

etc etc .. just ask.

email me at: lezanderson (at) gmail (dot) com

Good Luck and keep up the good work ! =D>
Last edited by 1024MAK on Thu May 25, 2017 6:01 pm, edited 1 time in total.
Reason: Email address edited to prevent easy access by robots

eXne
Posts: 15
Joined: Wed Apr 06, 2016 7:15 am
Location: Haarlem, The Netherlands

Re: 6809 experiments

Postby eXne » Thu May 25, 2017 4:36 pm

I probably have a couple of 6809 CPU laying around which I can donate

User avatar
sydney
Posts: 1987
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

Re: 6809 experiments

Postby sydney » Thu May 25, 2017 6:28 pm

Direct page sounds interesting. Is it possible to repeatedly alter the register pointing to direct page as so that a whole program could be written using faster direct mode instructions?

dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

Re: 6809 experiments

Postby dominicbeesley » Fri May 26, 2017 11:04 am

Thanks lads,

Thanks Lez, I'm ok for chips at the moment. In the end I went for the slightly more modern EPM240/570 CPLDs - these need a bit of level shifting to work so are not that easy to work with on the hardware level but have the benefit of being supported by more modern software. I couldn't get any of the design software for the older chips to install - you need a "free" licence key but the licence key generator page doesn't work and no reply from support! And the slightly more modern 7128s while still sort of supported aren't covered by the latest software versions. I may revise this though as they are nice chips!

I may take you up on the offer of the loan/swap of a sound chip, I've got the 76489 working and even started on a tracker player module but theres only so much you can do with 3 channels of square wave and a channel of fart. If you'd pick one of the other 8-bit era chips, other than SID, which would it be. I'm planning on having a socketed SID on board at some point...

The eXne, I've got another 6309 coming from China, and probably shouldn't get any more chips just yet. At some point I may get motherboards that other can try out...they will probably be too expensive to produce to make them popular but as the minimum order is 5 I'll be offering them round when I get to a point where they're a bit more refined and fit in a case. So you might want to hang on to your chip until then!

syndey, yes it is - so far I've not used it for much, I've just set it to 0 and left it there to make porting easier but it should be possible to use it for some optimisations, I was thinking the graphics routines in the MOS might benefit from them but not really thought it through as the direct page addressing modes are fairly limited. I really need to find some "tips and tricks" on 6809/6309 coding as I'm sure there are plenty of hacks that I'm not aware of.

D

dominicbeesley
Posts: 466
Joined: Tue Apr 30, 2013 11:16 am

Re: 6809 experiments

Postby dominicbeesley » Mon May 29, 2017 7:54 pm

A major milestone achieved today, boot to BASIC with sound and keyboard. Now it's starting to look and feel like a real beeb!

https://www.youtube.com/watch?v=Gbo8-MU-6Lo

D

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: 6809 experiments

Postby roland » Mon May 29, 2017 8:15 pm

That looks impressive =D>

Did I miss something? Is there already a bbc basic port for the 6809 or did you create it? (If so ... How did you do that in so less time? )
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
fordp
Posts: 923
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England

Re: 6809 experiments

Postby fordp » Mon May 29, 2017 8:21 pm

Well done very interesting. Is this an open source project and have you posted up any code yet?
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

User avatar
Elminster
Posts: 1632
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK

Re: 6809 experiments

Postby Elminster » Mon May 29, 2017 8:33 pm

dominicbeesley wrote:A major milestone achieved today, boot to BASIC with sound and keyboard. Now it's starting to look and feel like a real beeb!

https://www.youtube.com/watch?v=Gbo8-MU-6Lo

D


Stick it all in a case to hide the wires and bits of board, and job done :)

RobC
Posts: 1823
Joined: Sat Sep 01, 2007 9:41 pm

Re: 6809 experiments

Postby RobC » Mon May 29, 2017 9:20 pm

Great work - such an achievement to get this far!


Return to “hardware”

Who is online

Users browsing this forum: Bing [Bot] and 9 guests