From owner-freebsd-current Fri Dec 8 15:43:44 2000 From owner-freebsd-current@FreeBSD.ORG Fri Dec 8 15:43:41 2000 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mail.interware.hu (mail.interware.hu [195.70.32.130]) by hub.freebsd.org (Postfix) with ESMTP id 575F037B400; Fri, 8 Dec 2000 15:43:40 -0800 (PST) Received: from mogadishu-35.budapest.interware.hu ([195.70.52.99] helo=elischer.org) by mail.interware.hu with esmtp (Exim 3.16 #1 (Debian)) id 144XAv-0001yr-00; Sat, 09 Dec 2000 00:43:37 +0100 Sender: julian@FreeBSD.ORG Message-ID: <3A31720D.9A6CFF63@elischer.org> Date: Fri, 08 Dec 2000 15:43:09 -0800 From: Julian Elischer X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en, hu MIME-Version: 1.0 To: Matt Dillon Cc: John Baldwin , current@FreeBSD.ORG Subject: Re: __asm help.. References: <200012082129.eB8LTMM22955@earth.backplane.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 -- 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