[Coco] VCC and my code tinkering.
zambotti at iinet.net.au
Tue Jul 25 04:10:30 EDT 2017
Let me clarify those millions of times per second.
Let begin with a CoCo with 8x8K banks accessable by the CPU from a total of 64 x 8k memory pages.
Let's say for example that OS9 loads a module stored page 10 into bank 0.
This module is written to access device registers in the FF00 range. This would represent the top bank or bank 7. Now OS9 realises that this module is only 8k in size so it remaps the same block in bank 7.
Our map now looks like this:
Bank - Page
0 - 10
1 - don't care (DC)
2 - DC
3 - DC
4 - DC
5 - DC
6 - DC
7 - 10
So the module in page 10 is mapped into both bank 0 and bank 7.
Now imaging this piece of code
A Ldx $FFFF
Lda 0,Y ' load a from where Y is pointing
My 6809 code is not exact but you have a tight loop accessing some IO port.
The cpu loads instructions from bank 0 and immediately loads data from bank 7.
Now on the CoCo you can have page 10 in both banks so no swapping is required. But in AWE page 10 can only be in one bank at any one time so the load instruction causes a page swap and the load data causes another page swap. So the Lda 0 ,Y causes two swaps in one instruction.
On a 25 mhz emulator at about 15 cycles for the tight loop that equates to more than 1million swaps per second.
Also no bank swapping occurs on the CoCo hardware just because the cpu and GIME want to access the same memory at the same time. Because the CPU uses the top or bottom of a cycle and the GIME uses the opposite. But in AWE this is not possible in order to share the memory it must be constantly swapped between sharing devices.
From: Coco [mailto:coco-bounces at maltedmedia.com] On Behalf Of Kip Koon
Sent: Tuesday, 25 July 2017 3:49 PM
To: 'CoCoList for Color Computer Enthusiasts' <coco at maltedmedia.com>
Subject: Re: [Coco] VCC and my code tinkering.
That is very interesting. I did not know some of that. Thank you for sharing these discoveries you made and learned. I knew that it was possible for the Coco MMU to map the same page of memory in multiple areas of the 64KB memory map. I was just not aware of the fact that this happened between the CPU and the GIME millions of times per second for every instruction! Wow! Our little Coco is quite busy switching memory pages!
My blood sugar bottomed and as I have just eaten to take care of this, I find this information very interesting to try to process mentally. Typing is also quite interesting to accomplish with my hands shaking as they are. :) I guess I'll stop for now since I'm having to correct a lot of mistakes as I go on in this email. It's interesting to say the least. Oh wow, my mind just slowed waaay down for a moment. Hmmm. I think I need some more food. See ya! :) Keep up to great work and thank you for sharing! Take care my friend.
computerdoc at sc.rr.com
From: Coco [mailto:coco-bounces at maltedmedia.com] On Behalf Of Walter Zambotti
Sent: Tuesday, July 25, 2017 2:36 AM
To: 'CoCoList for Color Computer Enthusiasts'
Subject: [Coco] VCC and my code tinkering.
For anyone interested.
I have just finished integrating Windows Address Windowing Extensions with VCC.
Window AWE allows the user to control which pages of physical memory are mapped into virtual memory.
Or in other words it is a memory paging management device similar to the CoCo MMU unit.
My goal was to determine if using hardware memory management would speed up the VCC emulator (which currently only uses software) for Windows users only.
The bottom line is I got it going but it slows down the emulator by about 50%. (So half the speed)
The primary reason is because the CoCo MMU allows the same page of memory to be mapped into different memory banks multiple times simultaneously and AWE does not allow this.
I managed to overcome this limitation in AWE by allowing memory access violations to occur and used exception traps to remap the banks in real time to where they were needed.
This is fine if accesses to multiply mapped pages are scarce. But as I found out they can occur on every single instruction (millions of times per second).
This results in page trashing.
The second problem related to the first is because AWE does not allow the same page to be mapped multiple times the CPU will have one map of memory (64K) but at the same time the GPU in the GIME needs to access the same pages in its own memory map. This results in pages being swapped everytime the GIME and the CPU wants to share memory (and they do all the time).
The only positive thing was I gained a better understanding of how the CoCo hardware works and how VCC emulates it!
Coco mailing list
Coco at maltedmedia.com
Coco mailing list
Coco at maltedmedia.com
More information about the Coco