Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!balu!tilmann@cosmo.UUCP From: tilmann@cosmo.UUCP (Tilmann Reh) Newsgroups: comp.os.cpm Subject: Re: System use of Z80 registers Message-ID: <6209@balu.UUCP> Date: 2 Dec 90 11:12:21 GMT References: <9011261759.AA10916@newton> Sender: news@balu.UUCP Reply-To: tilmann@cosmo.UUCP (Tilmann Reh) Organization: CosmoNet, D-3000 Hannover 1, FRG Lines: 36 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 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. 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... 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 ? Tilmann Reh tilmann@mcshh.uucp tilmann@mcshh.hanse.de