Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!news.funet.fi!news From: pl@news.funet.fi.tut.fi (Lehtinen Pertti) Newsgroups: comp.os.cpm Subject: Re: System use of Z80 registers Message-ID: <1990Dec4.134833.17783@funet.fi> Date: 4 Dec 90 13:48:33 GMT References: <6209@balu.UUCP> Sender: news@funet.fi (#News ) Organization: Finnish University and Research Network FUNET Lines: 64 From article <6209@balu.UUCP>, by tilmann@cosmo.UUCP (Tilmann Reh): > Hello world, > > 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. >> **** >> >> This rule ensures that an application that uses Z80 opcodes can run on >> any z80 system without having to save and restore any of those >> registers before every BIOS and BDOS call. > > That's a guideline I don't agree with. > Why should the system care about which registers the application program uses? The point is, that CP/M is specified to 8080 and first Z80 versions didn't use Z80-specific registers, so it appeared, that applications were free to use those registers without saving/restoring. Now, if new versions of CP/M take those registers in use, it could break old applications. > The responsibility for register contents is *only* at the application > program! So, before each and every system call it has to save those registers > it want's to use afterwards (assuming with unchanged contents). This also > reduces system overhead (thus increasing performance, though slightly) as > not every register that *might* be used has to be saved, but only those > that *are* used. System routine usually saves only those registers it really uses, so I don't really see, if it matters, who saves the registers, as long as it is clearly specified somewhere. > 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... > Yes, this is sure way to do that. But what is needed, is clear specification, which registers should be preserved and which not, just as in every subroutine calling standard. > Of course, interrupt routines must also save all registers they use, as this > are asynchronous events. > > When will programmers (system *and* application) finally understand that > everything should be programmed as portable and universal as possible ? > If system specification says which registers are to be preserved, it would be very easy. Up to that point there is always possibility to argue, who is brain damaged and who not. > > Tilmann Reh tilmann@mcshh.uucp > tilmann@mcshh.hanse.de pl@tut.fi ! All opinions expressed above are Pertti Lehtinen ! purely offending and in subject Tampere University of Technology ! to change without any further Software Systems Laboratory ! notice