Page 1 of 1

Target loading address for cp/m programs

Posted: Sun Apr 05, 2020 8:19 pm
by jacotton
<not certain where to land this>

I am working on a driver that will stay resident after loading. This driver is being written in 'C' using the
zcc commands and tools.

In CP/M 2.2 and 3.0 there is the concept of loading an extension to CP/M and expecting it to stay in memory.
This is done by adjusting the base address of CP/M via altering the low address pointer etc....

Now for the problem. I need to build and link my driver with a load address of say 8000 hex, and have all
the linking work out for that address. Then a loader will be used to place the binary and call an initialization
routine. After that the code should remain in memory and preform its driver functions until CP/M is restarted,
via reboot.

I don't see how this is done with z88dk. I presume the crt0 will need to be tweeked, but how do I tell the compiler/linker
what my address should be ?


Posted: Sun Apr 05, 2020 9:19 pm
by stefano
usually we leave support for the '-zorg=' parameter, we missed it on the CP/M, because it looked quite a fixed location.
I know the original CP/M had options for having the TPA at different locations, but it was rarely used and the applications couldn't run easily on a machine like that, so it's VERY unusual.
It's easy to add support for 'zorg', or you can edit the start-up code yourself: ... c_crt0.asm

What you already have is probably even better ;) If you build the program with adding the '-startup=2' parameter, it will link your program at $8000 and will provide a relocation routine, so you can load it as a normal COM program.
This feature was useful with those computers doing odd memory paging to support high resolution bitmapped graphics and looks like a good option for you as well.


Posted: Sun Apr 05, 2020 9:32 pm
by jacotton
will the -zorg= work for CP/M or is that a lot of code work on the compiler ?

Posted: Sun Apr 05, 2020 9:35 pm
by jacotton
well, it did not complain, but can't tell yet if that's working

Posted: Sun Apr 05, 2020 9:50 pm
by stefano
-zorg is missing, but it will be in very soon.

Can the other startup flag be useful in your case?

Posted: Mon Apr 06, 2020 12:03 am
by jacotton
Well, maybe. The driver is about 33kb at the moment, so its optimistic that it will fit, will need to
reduce the size before I can test it.

-zorg would let me test the code sooner.

Posted: Mon Apr 06, 2020 6:53 am
by stefano
Ok, -zorg is ready, it should be available tomorrow.
Otherwise you can pick the file from the link I provided already and replace the single file yourself (no need to rebuild).