Date: Thu, 17 Aug 95 16:06 MDT From: mat AT ardi DOT com (Mat Hostetter) To: "A.Appleyard" Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: inline asm? References: >>>>> "A" == A Appleyard writes: A> mat AT ardi DOT com (Mat Hostetter) wrote:- >> You could "pushal" them onto the stack and "popal" them when >> you are done. A> I hadn't heard of pushal and popal before. What PC processors A> can obey them? I prefer not to use 486-specific code while A> there are still many 386's about. Sometimes I have to write A> Gnu C++ programs for compiling for people in my department to A> run on other PC's. 80386 and up. They are standard opcodes (called pushad/popad in Intel syntax, which may be why they don't look familiar). A> In my manual of interrupts, the descriptions of most A> interrupts include a long list of registers which are clobbered A> by that interrupt, so I feel safer saving every register every A> time. I don't think you understand what I was saying. gcc's calling convention allows certain registers (%eax,%ecx,%edx I think) to be clobbered by subroutines. There is no point whatsoever to save and restore those registers in a subroutine (gcc doesn't bother). You're right in that you should explicitly preserve the other registers preserved by the C calling convention; what I'm saying is that you don't need to save them all. A> I also find it easier to read to: write the interrupt's args to A> `long _ax' etc; swop _ax etc with the registers; call the A> interrupt; swop back; pick the interrupt's results out of _ax A> etc. Readability is always a concern, and often the performance hit is worth it. Personally I'd find it easier to understand code which didn't reuse its input/output array for temporary storage during the subroutine, but your mileage may vary. Let's take this to private email after this... -Mat