Re: Hardware emulation of 6509 using 6502?

From: Mia Magnusson <mia_at_plea.se>
Date: Sat, 28 Jul 2018 12:34:50 +0200
Message-ID: <20180728123450.0000699d@plea.se>
Den Sat, 28 Jul 2018 02:00:20 -0500 skrev Jim Brain <brain@jbrain.com>:
> On 7/25/2018 4:03 AM, smf wrote:
> > On 24/07/2018 07:30, Jim Brain wrote:
> >
> >>> Can you set new $0/$1 while in 65816 that take effect when
> >>> switching back to 6509?
> >> Sorry, but the registers disappear in '816 mode
> >>
> >>>
> >>> And the same for setting the 65816 environment from 6509 mode
> >>> before switching?
> >> nope, sorry.
> >
> > Does this mean you can only switch from 6509 to 65816 from a
> > routine in bank 0?
> Yes, and I think that's OK, as Bank 0 is always known to exist in
> both environments.

Bank 0 doesn't exist on a B, only on a P!

(I really don't know why the B uses bank 1-4 instead of 0-3. To make it
more confusing the 6509 bank 1-4 is seen as address 0 - (256k - 1) from
the 8088 coprocessor).

P has 64k VIC-II ram in bank 0, with badlines slowness, and bank 1
contains ram which is separate from VIC-II. Afaik the board can be
populated with ram for bank 2 and 3 too, but there is no space for bank
4.

> > The PBR will be 0 at startup and you can't change it until you're
> > in 65816 mode. You can leave the PBR set when you return to
> > emulation mode, but if an interrupt occurs in emulation mode then
> > it gets set back to 0. So the only way to keep consistency is to
> > handle that transition from bank 0.
> Yes.
> >
> > And if you switched to 65816 in bank 0 and can't update $0/$1 in
> > 65816 mode, then returning to emulation mode needs to be done in
> > bank 0 as well.
> Yep.
> >
> > AFAICT Interrupts in 65816 mode will be fetched from bank 0 and in 
> > 6509 they will be fetched from bank 15.
> I don't know how interrupts can be fetched from bank 15, unless $0 is 
> set to 15, which it does not look like it is.

If the 65816 starts in a mode where it expects code in bank 0,
something has to be done to get it to work in a B.

I'm not that familiar with the 65816. If it starts executing code in
bank 0, what happens when it reaches address $FFFF? Will it wrap around
to $0 or will it continue on $1000? If it continues at $1000 you could
simply inject NOP's as long as it's at bank 0 (and at address 0 and 1 in
bank 1) and then let it continue with actual code from memory.

But as P0-P3/A16... anyway has to be handled by the CPLD, it might be
easier to fist switch the 65816 itself to 65816 mode and then write the
magic sequence to $1 to switch off the 6509 emulation. Then the 65816
could already be in bank 1.

This assumes that you'll only have a 65816 processor. If you'll have
both a 65816 and a 6502 it might need some other solution.

-- 
(\_/) Copy the bunny to your mails to help
(O.o) him achieve world domination.
(> <) Come join the dark side.
/_|_\ We have cookies.
Received on 2018-07-28 13:01:42

Archive generated by hypermail 2.2.0.