From owner-freebsd-hackers Tue Dec 10 11:57:41 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1622537B401 for ; Tue, 10 Dec 2002 11:57:39 -0800 (PST) Received: from mail.speakeasy.net (mail17.speakeasy.net [216.254.0.217]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8194843ED4 for ; Tue, 10 Dec 2002 11:57:33 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: (qmail 14432 invoked from network); 10 Dec 2002 19:57:39 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail17.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 10 Dec 2002 19:57:39 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.6/8.12.6) with ESMTP id gBAJvVuH063698; Tue, 10 Dec 2002 14:57:31 -0500 (EST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20021210154635.GC605@thegrail.rose.agilent.com> Date: Tue, 10 Dec 2002 14:57:33 -0500 (EST) From: John Baldwin To: Chuck Tuffli Subject: RE: registers not saved Cc: freebsd-hackers@freebsd.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 10-Dec-2002 Chuck Tuffli wrote: > I've been chasing down some weird panics in my CAM driver and have > noticed that functions don't seem to save all register values before > they modify them. > > For example, function A uses register ecx to hold the value of a pointer. Part way through, > function A calls function B which uses ecx as a loop index. The bad part is function B never > saves/restores the value of ecx and function A starts dereferencing garbage. > > An informal sampling of my driver seems to indicate that ebx gets > pushed/poped at entry/exit but ecx and edx don't. Does any of this > sound familiar? Thanks! Yes, eax, ebx, and edx are not "call-safe" registers. If you are writing your own function in assembly and you call a function you need to either save those registers yourself or reload their values. If you are writing a function called by other functions your function needs to preserve ebx, ebp, esi, and edi either by saving and restoring them or by not changing their values. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message