www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/08/17/19:12:03

Date: Thu, 17 Aug 95 16:06 MDT
From: mat AT ardi DOT com (Mat Hostetter)
To: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: inline asm?
References: <AB10D301637 AT fs2 DOT mt DOT umist DOT ac DOT uk>

>>>>> "A" == A Appleyard <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019