Turbo-R cpu soft switch: how does it work?

페이지 1/2
| 2

By lintweaker

Champion (455)

lintweaker의 아바타

19-04-2020, 10:07

As we all know the Turbo-R can switch CPUs mid program and continue the currently running program with the alternate CPU.
I am trying to wrap my head around how the CPU being switched to can continue at the same RAM/ROM address? I know the registers are all saved to RAM.
Has anyone figured this out yet?

Login or 등록 to post comments

By Grauw

Ascended (10699)

Grauw의 아바타

19-04-2020, 11:03

Everything is pushed on the stack (just like the interrupt routine does), then one CPU is paused and the other resumed. The switching code makes sure each CPU is suspended in the same switching routine right in the middle of a big array of pushes and pops. If you want to know exactly you can read the turboR BIOS source code.

By lintweaker

Champion (455)

lintweaker의 아바타

19-04-2020, 11:30

Thanks guys. That commented code helps a lot. Now to see if I can translate this into some hardware logic.

By DarkSchneider

Paladin (965)

DarkSchneider의 아바타

19-04-2020, 11:39

I suppose it disables interrupts, and how long it takes?

By Grauw

Ascended (10699)

Grauw의 아바타

19-04-2020, 11:56

@DarkSchneider Yes it disables interrupts, but it’s a pretty short routine as you can see.

By DarkSchneider

Paladin (965)

DarkSchneider의 아바타

19-04-2020, 12:05

Then maybe is worth to switch for heavy CPU-VDP transfer operations?

By lintweaker

Champion (455)

lintweaker의 아바타

19-04-2020, 12:28

Still some more questions Smile
If I read correctly, it is stated that both CPUs start executing ROM code from 0000h. That is easier said then done ....(normally) only 1 cpu can access the bus (and therefore read the ROM) at a time.
The S1990 probably does some smart things here.

By zeilemaker54

Champion (345)

zeilemaker54의 아바타

19-04-2020, 20:11

Only one cpu has the bus. The inactive cpu halts until it has control over the bus again. This is standard z80 busreq/busack protocol and the s1990. On cold start z80 starts first, doing some initializing, then z80 halts and r800 doing some initializing. Then z80 is selected again and r800 halts. Z80 is doing the rest of the system initialization.

By Grauw

Ascended (10699)

Grauw의 아바타

19-04-2020, 21:37

DarkSchneider wrote:

Then maybe is worth to switch for heavy CPU-VDP transfer operations?

Generally not, because in R800 mode the S1990 throttles VDP access speed to 54 cycles @ 7.16 MHz per transfer. That’s 27 cycles @ 3.58 MHz. In Z80 mode both OUTI and OTIR are quite a bit faster, 18 and 23 cycles @ 3.58 MHz respectively.

So R800 mode is actually only beneficial when you process the data while loading it to VRAM, so that the spare cycles in-between transfers are used, otherwise for straight transfers the Z80 is faster.

By sdsnatcher73

Prophet (3838)

sdsnatcher73의 아바타

19-04-2020, 21:49

Grauw wrote:
DarkSchneider wrote:

Then maybe is worth to switch for heavy CPU-VDP transfer operations?

Generally not, because in R800 mode the S1990 throttles VDP access speed to 54 cycles @ 7.16 MHz per transfer. That’s 27 cycles @ 3.58 MHz. In Z80 mode both OUTI and OTIR are quite a bit faster, 18 and 23 cycles @ 3.58 MHz respectively.

So R800 mode is actually only beneficial when you process the data while loading it to VRAM, so that the spare cycles in-between transfers are used, otherwise for straight transfers the Z80 is faster.

I think what DarkSchneider means is: suppose you are in R800 mode and your game/program needs to do a large transfer to VDP, it might be wise to switch to Z80 mode before the transfer and then back afterwards. If the cost of the 2 switches is less then what you save on the transfer that seems beneficial.

페이지 1/2
| 2