Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 08 Dec 2000 15:43:09 -0800
From:      Julian Elischer <julian@elischer.org>
To:        Matt Dillon <dillon@earth.backplane.com>
Cc:        John Baldwin <jhb@FreeBSD.ORG>, current@FreeBSD.ORG
Subject:   Re: __asm help..
Message-ID:  <3A31720D.9A6CFF63@elischer.org>
References:  <XFMail.001208104618.jhb@FreeBSD.org> <200012082129.eB8LTMM22955@earth.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Matt Dillon wrote:
> 
> :As long as gcc uses %ebp to address local variables and functoin parameters
> :rather than %esp you should be fine.  %esp will be preserved, but if %esp is
> :for some odd reason used to address a variable during the C code, you are hosed.
> 
>     I strongly recommend against making assumptions about GCC's use of %ebp vs
>     %esp... not if you want the __asm code to survive the GCC optimizer!
> 
> :Just use foo = save_intr(); disable_intr(); .. restore_intr() for now.  If you
> :want to save the 2 instructions so badly, then you should probably be writing
> :the whole chunk in assembly.  Getting it correct first and optimizing later is
> :more sane than getting correctness and optimization at the same time and not
> :knowing which one your bugs are coming from.
> :
> :John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
> 
>     Yah, gotta agree there.  The only thing that matters, Julian, are memory
>     accesses.  The number of instructions you use is irrelevant.

foo = save_intr(); disable_intr(); .. restore_intr()
has 4 extra memory accesses.

pushf (the only way to save interrupt state) save to stack.
save_intr() reads it back off the stack 
(ok a cache hit I suppose)
and writes it to a memory location specied as an argument.
(Not a cache hit..)(though maybe defered)
After some processing, 
restore_intr() then reads it from the nominated address
(probably a cache hit) 
and puts it on the stack.
(not a cache hit). (though maybe defered)
it is then read off the stack by popf 
(a cache hit).

Since all I WANT to do is 
pushf
disable intr
fiddle
popf (chache hit)

I am annoyed by the fact that I have all those extra bus cycles going on.
I can live with it for development but it still annoys me.

> 
>                                         -Matt
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-current" in the body of the message

-- 
      __--_|\  Julian Elischer
     /       \ julian@elischer.org
    (   OZ    ) World tour 2000
---> X_.---._/  presently in:  Budapest
            v


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A31720D.9A6CFF63>