• Please review our updated Terms and Rules here

Banked memory questions

Mano

New Member
Joined
Sep 29, 2023
Messages
2
Hello,
please forgive my ignorance. After doing some online research i only found partial answers to a few questions i have on CP/M Z80 and i hope someone here can clarify a bit.
Unfortunately i have no first hand CP/M experience from back then, jumped directly from a C64 to a DOS XT ...

I'm interested in the bank switching in CP/M Plus/3.
From what it found, it seems that the extra memory of a CP/M Plus system is only used by the system itself, to move most of its code "out of the way" so the programs see more free low memory.
Some Versions of CP/M Plus use more memory to also store file buffers, or keep the CCP in RAM all the time.
But any given program still will only use a maximum of , with a 4+60k banking scheme, 60k RAM.

There is no mechanism in the OS that allows commercial off the shelf programs to use multiple banks of memory, right?
Did something like "Wordstar 4.0 running on a CP/M Plus machine with 256 KB of RAM can hold a 130 KB document completely in RAM" exist?

thank you,
Mano
 
Yes, welcome to VCFED - as this is your first post.

I have never used CP/M 3 but, from what I remember, there are additional BIOS routines (note, not BDOS) to manage the bank switching and (in particular) copying data from bank to bank.

Also, given the ingenuity of programmers to achieve an aim, they will 'bend' a system to make it do what they want...

Been there, done that, got the T shirt!

Dave
 
Like of lot of CP/M, the exact hardware mechanism for memory banking in CP/M 3. was never called out and left to the vendor. We ran it for a time with 1K banks. And there was no specific user API provided for cross-bank applications.
 
Hello,

I've got my Amstrad PCW still working as a CP/M 3 machine, with 512k of RAM.

Various books for the PCW, and published articles from the day, regarding software, show how to use standard routines to mess with the RAM, and swap banks in and out of 'active'. Yes, there is no clear API for doing this, but it's fairly simple to do, and if you follow the rules, then it's no problem.

As much of the screen stuff, and BIOS, is in banked memory, if you mess with graphics, or character gen, or need to do things with the DPB, etc, then you need to swap banks.

What in detail do you want to do. I may have some 'ready to run' routines? Or can direct you to some useful sources.

Geoff
 
Thank you for the welcome and answers.
This was mostly a generic "want to know" question.
I remotely think of building an own CP/M capable Z80 machine, or extend a C128 beyond 128K, but as there is no platform independend way of supporting such memory, and i don't want to start and adapt applications just for that system, it probably makes litte sense.
 
Specific questions asked that I missed answering..

I don't know if this varied, but the PCW uses 16k banks, so there are 4 for the normal 64k, plus a number of active switchable ones for screen memory, BDOS, BDOS, etc. The BULK of the RAM though is config as a RAM disk, M:, and this is not accessible as RAM. Wordstar Can make use of extra RAM by using M: as the working disk, with substantial speed benefit, but not directly. I have run WS in this way, but not v 4

The PCW system does however have various games available, where the system is set up quite differently, and here ALL the RAM is available to the game, graphics, data, etc (so CP/M is not loaded at all), so clearly such things are possible.

The DR documentation for installing CP/M+ will have full details of these options.

Geoff
 
The lack of standardization for bank switching no doubt ranks really high among the reasons why 8088-based PCs crushed CP/M so quickly. People gripe about 8086's segmented memory model but it was far more flexible than most 8-bit machines' memory banking systems and was built right into the CPU.
 
With our 1K mapped scheme, we could have had shared code and data. Moving data in 1K blocks was mostly a matter of changing the map. The 16K bank thing is really primitive.
 
Hi @Mano

Did something like "Wordstar 4.0 running on a CP/M Plus machine with 256 KB of RAM can hold a 130 KB document completely in RAM" exist? thank you, Mano

Yes, it did exist, and it's what I've been recreating and extending. The only really consistent element of CP/M that I discovered was the BDOS, so that's where I began with a new architecture.

It starts with a simple premise. In CP/M, with more memory and a utility to create a RAM disk, you can store files in the RAM disk. Amstrads did this, and the 512K models have a reasonable sized RAM disk which makes it pretty useful to keep a document in RAM until you want to save it permanently.

So I've been extending on this idea with LokiOS which is a new compatible version of CP/M on a hardware architecture that extents it to the point that it still works if you swap back in the original CP/M BDOS and CCP.

It's still at a primitive stage, but it is publicly released now, and while the LokiOS itself might not be relevant to what you're doing, the architecture might be.

It makes everything work as a "Disk" file or "Memory" or "I/O Space" and ends up with a really neat converged architecture which lets you switch memory between disk and direct memory and i/o memory access on the fly, all managed by CP/Ms BDOS using the CP/M disk format as a defacto MMU. Since it's a converged memory space, I call it "Memory As Disk" or MAD.

It's a bit complex to describe it like that, but it does work, and it works with plain standard CP/M 2.2. You don't need CP/M 3 or concurrent, and it lets you create things like drivers, handlers, resident routines etc, all while leaving the 64K TPU mostly alone and an application can run in RAM using system memory to store files ( I use M: drive for this - any memory use appears like a file in M: and doing a DIR of M: shows me where memory is used, and by what, and CP/M utilities will even tell me which memory is being used, allow memory to be released and reallocated automatically, and a CP/M COM file can even be larger than 64K, though I haven't tried that with real CP/M yet, and it can either open it's higher memory through the BDOS or just page it in directly via extensions. )

This also lets me support 128K of video ram in the MAP and use both bitmapped graphics and normal text graphics without needing to use any memory space for a character map in the TPA.

As an example, let's say a basic program ( using MS BASIC which is unaware of the extra memory ) wants to access the 512x192 graphics directly without using system calls..

* You can open "videomem.img" as a random space, and write it as disk.
* You can use the Sector and Track ports and write it in blocks of 128 bytes or as individual bytes specifying which byte you want as a 20 bit address using three control bytes ( 7 bits lower address, 5 bits higher address, 8 bits segment address )
* You can pick a segment in memory ( 4K ) and have the disk system switch it into your TPA space and just access it as normal memory like you would do with a paging system.

Later I'll add bios calls for some tasks to make things easier. There's some other stuff like Process IDs which allow quick switching in and out of drivers without the OS being aware of it ( eg, calling the video display routines in a MS-DOS like way, it pages out the TPA pages as necessary and pages in the video drivers and video window, then restores the calling pages using a RAM as a cache-like MMU and using the Process ID to validate which memory map should be used ).

The cool think about this, is that you don't need to know where the memory is located. if the video card moves, it still works, unless you don't use the BDOS as the MMU. It also extends to 256Mb, but could easily be pushed beyond that.

You can try it out here: https://github.com/cj7hawk/LokiOS

You will need to download FreeBASIC to build the source (I'm wondering if I should just include binaries anyway) and it boots into a virtual 512x256 video screen and a CP/M prompt.

David
 
Back
Top