Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uw-beaver!zephyr.ens.tek.com!tektronix!percy!nosun!techbook!fzsitvay From: fzsitvay@techbook.com (Frank Zsitvay) Newsgroups: comp.os.cpm Subject: Re: System use of Z80 registers Message-ID: <1990Dec12.024519.7306@techbook.com> Date: 12 Dec 90 02:45:19 GMT References: <9011261759.AA10916@newton> <6209@balu.UUCP> <663@catnip.berkeley.ca.us> Organization: TECHbooks of Beaverton Oregon - Public Access Unix Lines: 51 In article <663@catnip.berkeley.ca.us> bandy@catnip.berkeley.ca.us (Gun Control is Hitting Your Target) 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? > >Why? "Because CP/M is an **8080** operating system - thus it may only use >8080 registers." I got this reply back from Digital Research back in '80 >when I asked them about the Z/80 registers. well, CP/M itself doesn't use the special registers, but the BIOS might, since that was supplied from the manufacturer of the machine. there is another problem, though, in that some z-80 BIOS' were written in such way that the index registers of the z-80 as well as the alternate register set were used as temporary storage between calls, and applications that used these registers would bomb on machines that expected those values to still be there. CP/M itself (for BDOS calls) doesn't preserve any registers. (which led to programs being littered with PUSH B! PUSH D! PUSH H and corresponding pops after each BDOS call) perhaps it would be best to assume the bios doesn't save the special registers in the z-80. but an unacceptable situation is where the BIOS requires the application to not change the value of those registers. sure, CP/M is an 8080 operating system, but since most CP/M machines still working these days are Z-80 based, then perhaps it should be considered a z-80 operating system. writing applications to run under z-80 CP/M should be free to use those registers, but not expect the operating system to preserve the contents. (exception - interrupt handlers.) people who own machines with a BIOS that does store values in special z80 registers would probably have to hack their BIOS so that it doesn't. those writing programs that use special z80 registers should PUSH them before a BDOS call and POP them after the call, assuming they need to save the contents of those registers. -- fzsitvay@techbook.COM - but don't quote me on that.... American Oil Company motto - Bend over, We'll pump!!!