<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Wed, 05 Dec 1990 21:27:16 GMT
From   : amethyst!organpipe!afthree.as.arizona.edu!tom@noao.edu (Thomas J. Trebisky)
Subject: System use of Z80 registers

>Bridger Mitchell writes:
>> I (and others) have long argued strenuously for strict adherence to
>> the following systems-programming guideline:
>>
>>                                ****
>>   SYSTEM CODE (BIOS, BDOS, INTERRUPT-SERVICE ROUTINES, AND BACKGROUND
>>   UTILITIES)  SHOULD *ALWAYS PRESERVE* THE NON-8080 REGISTERS.
>>                                ****
>
> Tilmann Reh writes
>The above guideline opens the door to very improper application programming.
>The only way to ensure that a program runs on *every* CP/M machine is to
>save all registers which must stay valid prior to any system call. BTW, I
>don't see why this should be so hard...

Sorry to take exception with this. I don't think it is the applications
programmers responsibility to guard against all manner of stupidity on the
part of those writing systems code. Believe me, every modern OS puts the
burden of saving and restoring machine state on the OS -- on a Unix system
a system call is commonly implemented by a TRAP or INT, and the first thing
the OS will do is save all the registers and whatever else is involved with
the user context so it can restore it transparently.  As you point out there
is no possible way that user code can "guard against" what is done with
registers in interrupt routines since they are completely asynchronous.

The sad reality of things though is that you are right in a way,
due to the abundance of funky systems software in the CPM realm.
In the hey-day of CPM every Tom, Dick, and Harry was in a rush to port CPM
to this or that platform, and some of the work was poorly done.
This forces you and I to go to lengths we shouldn't have to, if we really
want "portability" to every sleaze-ball system.  However if the above 
guidelines for SYSTEMS code were followed, we would not have to do this.
Another case could be made perhaps for efficiency, the applications
programmer knows at any time exactly what he needs to save, whereas a
systems call handler must necessarily save everything to be general.
In the Z80 realm where every machine cycle is precious, this might have
merit, but I would rather save the code space (and my keystrokes :-) ).


End of INFO-CPM Digest V90 Issue #197
*************************************
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>