Page 1 of 1
Wanted: 6502 Tube emulator (just the second processor)
Posted: Wed Jul 19, 2017 10:00 pm
by hjalfi
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?
Re: Wanted: 6502 Tube emulator (just the second processor)
Posted: Fri Jul 21, 2017 4:41 pm
by SteveF
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.
Re: Wanted: 6502 Tube emulator (just the second processor)
Posted: Fri Jul 21, 2017 5:39 pm
by DutchAcorn
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?
Re: Wanted: 6502 Tube emulator (just the second processor)
Posted: Fri Jul 21, 2017 6:59 pm
by SteveF
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!)
Re: Wanted: 6502 Tube emulator (just the second processor)
Posted: Fri Jul 21, 2017 7:56 pm
by BigEd
Great! I've a feeling I tried to do something like this in the past and got bogged down.
Re: Wanted: 6502 Tube emulator (just the second processor)
Posted: Sat Jul 22, 2017 9:17 pm
by jgharston
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.
Re: Wanted: 6502 Tube emulator (just the second processor)
Posted: Thu Jul 27, 2017 8:16 pm
by hjalfi
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.
Re: Wanted: 6502 Tube emulator (just the second processor)
Posted: Fri Jul 28, 2017 4:30 pm
by SteveF
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.
Re: Wanted: 6502 Tube emulator (just the second processor)
Posted: Fri Jul 28, 2017 10:01 pm
by hjalfi
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?