Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Dec 2002 14:57:33 -0500 (EST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Chuck Tuffli <chuck_tuffli@agilent.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   RE: registers not saved
Message-ID:  <XFMail.20021210145733.jhb@FreeBSD.org>
In-Reply-To: <20021210154635.GC605@thegrail.rose.agilent.com>

next in thread | previous in thread | raw e-mail | index | archive | help

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 <jhb@FreeBSD.org>  <><  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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20021210145733.jhb>