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 <[EMAIL PROTECTED]> <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message

