Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!gatech!hao!ames!oliveb!pyramid!decwrl!sqm.dec.com!jmsynge From: jmsynge@sqm.dec.com (James M Synge, DTN 381-1545) Newsgroups: comp.sys.amiga Subject: Re: Printer drivers and Aztec 3.04a Message-ID: <9796@decwrl.DEC.COM> Date: Sat, 9-May-87 18:14:55 EDT Article-I.D.: decwrl.9796 Posted: Sat May 9 18:14:55 1987 Date-Received: Sun, 10-May-87 08:42:42 EDT Sender: daemon@decwrl.DEC.COM Organization: Digital Equipment Corporation Lines: 52 ---------------------Reply to mail dated 4-MAY-1987 19:57--------------------- cardovax!kaz (Kerry Zimmerman) writes > I eventually isolated the problem by using the +AT option to get > the assembly source for render.c. What I determined (using DB) > was that register A6 is used by render, but not saved and restored > before and after the routine. As a result, the printer.device who > calls render, and who expected A6 to be preserved, crashed. ... > My question is shouldn't A6 have been protected automatically by > the compiler? Unfortunately this isn't the only register which goes unprotected by Aztec 3.4, but is nearly always the cause of all problems. A4 is also not saved, but even though the docs say that it can be used for storing register variables, my experience has been that Aztec C never uses A4 for anything other than as the program base pointer. SO... If you write any C code, and compile it with Aztec C, which can be called by any language other than Aztec C, then you will very likely have to write some assembly language to protect A4/A6. And great care must be taken when doing so. If the arguments are on the stack, then you cannot push the registers on to the stack because then the args will be in the wrong place. But! If your code is to be reentrant, then you can not use a static location for the resister backup. If the args are in registers, then you may be able to push them on to the stack. For this latter case, the code might look like this: public _sub ; long sub(char *, long) (A0,D0) public __sub __sub movem.l A4/A6,-(sp) ; Save the registers move.l D0,-(sp) ; Push the second arg move.l A0,-(sp) ; Push the first arg jsr _sub ; Call the C routine addq.l #8,sp ; Pop the args (sort of) movem.l (sp)+,A4/A6 ; Restore the registers rts ; Return Good luck! James Synge USENET: {decvax, ucbvax, allegra}!decwrl!sqm.dec.com!jmsynge ARPAnet: jmsynge%sqm.DEC@decwrl.DEC.COM #include "Ken Olsen can speak for Digital, not me!"