mem@sii.UUCP (Mark Mallett) (11/28/83)
b
This article describes a change to one of the modules supplied by
Manx Software Systems for their CP/M Aztec C compiler. The module
is `callcpm.asm', and the change makes it possible for the C
programmer to have control over whether or not the CCP (a part of
the CP/M operating system) gets overlaid. Overlaying the CCP is
standard, and results in more memory being available to the program.
However it requires a partial reboot of the system. For applications
which don't require the extra memory, NOT overlaying the CCP is more
pleasant, for it allows a program to come back to CP/M immediately.
The changes are to the first 2 routines in `callcpm.asm', and an
additional data declaration later on in the file. Only the pertinent
parts are shown here. You'll have to edit this in to your existing
file, then merge it into the library `libc.lib' or `libcz80.lib'.
The first routine - `.begin' - is the routine which gets control
from the operating system. It is not C-callable.
The second routine - `boot__' - is called by exit(). If you put this
change in, don't call it and expect a system boot. Call CPM (0,0)
instead. Note also that to make full use of this change, you should
arrange to pass a 0 value to exit(), as any other value is taken to be
an indication of error; the result being that the file $$$.SUB (the
batch mode command file) is deleted. This deletion causes a directory
access and slows down the exit to CPM. (The return value from main()
is passed to exit().)
An example of how to use this change:
bof->
char ovlccp = {0}; /* Flag to runtime system not to overlay
the CCP */
main()
{
printf ("hello.\n");
}
eof->
Mark E. Mallett
decvax!sii!mem
=====================================================================
;Copyright (C) 1981,1982 by Manx Software Systems
; Copyright (C) 1981 Thomas Fenwick
;
; Modified:
;
; 831127 mem (Mark E. Mallett).. Changed the entry and exit
; sequence to check for an externally defined flag (char)
; `ovlccp'. If this flag is false, the CCP will not be
; overlayed, and the boot_() entry point (used by exit())
; will return to CCP rather than reboot. If this is true,
; then the CCP will be overlayed and boot_() will boot.
; Note that the flag may be changed after the program starts
; to force a boot.
;
BASE equ 0
BDOS equ 5
CSEG ; *mem*
COMMON /ovlccp_/ ; *mem* overlay CCP flag
F$OVCCP: DS 1 ; *mem*
CSEG
ext Croot_
public .begin
public boot__
.begin:
POP H ; *mem* Get return address
SHLD R$ADDR ; *mem* Save it
LHLD 6
LDA F$OVCCP ; *mem* Check overlay CCP flag..
ORA A ; *mem* .
JNZ begin1 ; *mem* Jump if flag true.
LXI D,-0800H ; *mem* minus size of CCP
DAD D ; *mem* offset ...
begin1: ; *mem*
SPHL
CALL Croot_
boot__:
LDA F$OVCCP ; *mem* Check CCP overlayed flag
ORA A ; *mem*
JNZ bootb ; *mem* if so, really boot!
LHLD R$ADDR ; *mem* Get return address
PCHL ; *mem* Jump to there
bootb: ; *mem*
lxi b,0
call BDOS
JMP bootb ; *mem*
.
.
.
public $MEMRY
public R$ADDR ; *mem*
DSEG
$MEMRY: dw 0ffffH
R$ADDR: DW 0 ; *mem*
CSEG
.
.
.