Target loading address for cp/m programs

Other misc things
Post Reply
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Target loading address for cp/m programs

Post 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 ?

tnx
jc
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post 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:
https://github.com/z88dk/z88dk/blob/mas ... 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.

Stefano
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Post by jacotton »

will the -zorg= work for CP/M or is that a lot of code work on the compiler ?
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Post by jacotton »

well, it did not complain, but can't tell yet if that's working
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

-zorg is missing, but it will be in very soon.

Can the other startup flag be useful in your case?
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Post 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.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post 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).
Post Reply