Wanted: 6502 Tube emulator (just the second processor)

want to talk about MESS/model b/beebem/b-em/electrem/elkulator? do it here!
User avatar
hjalfi
Posts: 74
Joined: Sat May 13, 2017 10:17 pm
Location: Zürich, Switzelrand
Contact:

Wanted: 6502 Tube emulator (just the second processor)

Postby hjalfi » Wed Jul 19, 2017 10:00 pm

Okay, this is a bit of a weird one.

I am looking for an emulator for a 6502 (well, 65C102) second processor. Not the I/O processor, just the second processor. Has anyone heard of this?

What I want to do is to run compiler tests, so I want to be able to load a program into the second processor and then run it once, with the stub MOS hooked up to a very very simple emulated I/O processor (just supporting stuff like file access and input/output streams mapped to host stdin/stdout, no VDU emulation or anything like that). That way I can effectively run a simple BBC MOS program in a way which is compatible with my Unix-based build system.

It should be relatively simple to bodge one together via lib6502, but I'd rather not have to. Has anyone ever heard of such a thing?

SteveF
Posts: 439
Joined: Fri Aug 28, 2015 8:34 pm

Re: Wanted: 6502 Tube emulator (just the second processor)

Postby SteveF » Fri Jul 21, 2017 4:41 pm

I started to hack something very much like this together out of the 'run6502' demo supplied with 'lib6502' - I took the Tube client ROM from Acorn's 65Tube emulator for RISC OS and started implementing the special opcodes, so I could have '65Tube for Unix', in effect.

I think the approach is workable but I got fed up with the fiddly details and stopped. If no one has anything better I could push my code up to github if you're interested in maybe making some enhancements.

I would like to see something like this myself, it would be nice for testing things like my PLASMA port where all you need is basic 'teletype' I/O.

ETA: Sorry, reading/writing this on phone and didn't see your mention of lib6502, so perhaps not very helpful. But just possibly what I already bodged together would be good enough for your needs without much/any extra work.

User avatar
DutchAcorn
Posts: 1633
Joined: Fri Mar 21, 2014 9:56 am
Location: Maarn, Netherlands

Re: Wanted: 6502 Tube emulator (just the second processor)

Postby DutchAcorn » Fri Jul 21, 2017 5:39 pm

I assume that you know BeebEm has selectable 65c102 second processor emulation. I don't know how accessible the source code is but it may be a usable start?
Paul

SteveF
Posts: 439
Joined: Fri Aug 28, 2015 8:34 pm

Re: Wanted: 6502 Tube emulator (just the second processor)

Postby SteveF » Fri Jul 21, 2017 6:59 pm

FWIW, I just slightly tidied up my lib6502-based hack and pushed it to github. It's at https://github.com/ZornsLemma/lib6502-sf.git.

Here's a brief demonstration... You'll need to get Code064.rom and (for this demonstration only) HiBasic430 yourself - they're not in the repository. You can get them from mdfs.net at http://mdfs.net/Software/Tube/6502/ and http://mdfs.net/System/ROMs/Language/ respectively.

Code: Select all

$ make
[...]
$ ./run6502 -T -l f800 Code064.rom -l b800 HiBasic430
Acorn 6502 Tube

6502 Emulator OS 0.64 (19 Oct 1988)

65*GO B800
HIBASIC

>10FOR I%=1 TO 5
>20PRINT "Hello StarDot!"
>30NEXT
>RUN
Hello StarDot!
Hello StarDot!
Hello StarDot!
Hello StarDot!
Hello StarDot!
>LIST
   10FOR I%=1 TO 5
   20PRINT "Hello StarDot!"
   30NEXT
>


Don't be surprised if anything more sophisticated fails to work, but if you have any questions/suggestions I'll see what I can do... (Patches/forks also welcome, of course!)

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

Re: Wanted: 6502 Tube emulator (just the second processor)

Postby BigEd » Fri Jul 21, 2017 7:56 pm

Great! I've a feeling I tried to do something like this in the past and got bogged down.

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

Re: Wanted: 6502 Tube emulator (just the second processor)

Postby jgharston » Sat Jul 22, 2017 9:17 pm

hjalfi wrote:I am looking for an emulator for a 6502 (well, 65C102) second processor. Not the I/O processor, just the second processor. Has anyone heard of this?
...
Has anyone ever heard of such a thing?

Yes, it's called 65Tube.
I also wrote a version entirely in BASIC to demonstrate how to do it, 65TubeEm which is the same fundamental structure as 6809Tube and PDPTube.

Code: Select all

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

User avatar
hjalfi
Posts: 74
Joined: Sat May 13, 2017 10:17 pm
Location: Zürich, Switzelrand
Contact:

Re: Wanted: 6502 Tube emulator (just the second processor)

Postby hjalfi » Thu Jul 27, 2017 8:16 pm

Ha. Went away on holiday and hacked one up myself --- knew I should have checked the forums while I was away...

Mine's at https://github.com/davidgiven/cowgol/tr ... u/bbctube; there's just enough functionality there to run HiBasic. Unlike run6502 it doesn't need an OS ROM, as it emulates the OS layer directly. It's unfinished as I haven't done any file I/O calls yet but they'd be easy to add.

One oddity is that while everything else seems to work, entering a program ends up with mangled line numbers (or missing lines completely). Does HiBasic use decimal maths, by any chance? Could I be corrupting the decimal flag?

cZ80Tube looks really interesting (I can't use the BBC Basic ones), but sadly doesn't build out-of-the-box on modern machines --- looks like it's not including any of the required header files. I may have a look later, but I don't have time to fix it myself right now.

SteveF
Posts: 439
Joined: Fri Aug 28, 2015 8:34 pm

Re: Wanted: 6502 Tube emulator (just the second processor)

Postby SteveF » Fri Jul 28, 2017 4:30 pm

I think the corrupt line numbers is caused by a lib6502 bug - even the latest upstream may not have the fix (I submitted it but I think Ian was busy). You might want to get the lib6502 from my github repo and build your code against that - it has a fix in, and I believe my version of lib6502 will pass Klaus Dormann's test suite.

I'm afraid I can't remember what the bug was, but if you diff lib6502.[ch] from my repo with upstream it will probably be fairly obvious.

User avatar
hjalfi
Posts: 74
Joined: Sat May 13, 2017 10:17 pm
Location: Zürich, Switzelrand
Contact:

Re: Wanted: 6502 Tube emulator (just the second processor)

Postby hjalfi » Fri Jul 28, 2017 10:01 pm

Yes, that solves it --- thanks! As I want this for compiler tests, having correct emulation is kinda important...

One (related) question: HiBasic's HIMEM is reported as &8000. This seems wrong --- shouldn't it be &B800? I can see it using OSBYTE &83 and &84 to ask for the HWM and HIMEM, but of course these apply to the I/O processor only. The New Advanced User's Guide even mentions that on a second processor, OSBYTE &84 does not return HIMEM.

My understanding was that programs which have claimed the Tube (which is implicit in my emulator) get access to the entire address space from &0400 to &F800. HiBasic, having loaded at &B800, doesn't need to contact the OS to find out where its workspace is. So why is it using the wrong value?


Return to “emulators”

Who is online

Users browsing this forum: No registered users and 2 guests