[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    Re: Problem with pic16l_setled
From:       Uwe Doering <gemini () geminix ! org>
Date:       2005-07-28 7:59:28
Message-ID: 42E89060.3060700 () geminix ! org
[Download RAW message or body]

Rink Springer wrote:
> * Ludvig Strigeus (strigeus@gmail.com) wrote:
> 
>>I see this code:
>>
>>+ENTRY(pic16l_setled)
>>+	push	%ebp
>>+	mov	%esp,%ebp
>>+
>>+	movl	0x8(%ebp),%ebx
>>+	orl	$0x800,%ebx
>>+	call	pic16l_ledhlp
>>+	movl	$0x701,%ebx
>>+	call	pic16l_ledhlp
>>+
>>+	leave
>>+	ret
>>
>>With the standard x86 calling convention, you're not supposed to
>>modify ebx, esi or edi without saving them first. Try adding a
>>push/pop ebx around.
> 
> I doubt this is the problem (I've looked at other .s files like
> i386/i386/support.s, function ssdtosd, and they don't seem to do this).

Well, at least in 'support.s' of RELENG_4 register ebx _does_ get pushed 
onto the stack in function 'ssdtosd'.  I suppose this is true also for 
the other FreeBSD branches.

If you call a function from the C level only registers eax, edx and ecx 
may be altered without preserving their original contents on the stack 
(or wherever else).  That is, in C the calling level expects that the 
other registers survive a function call unharmed.  As pointed out that's 
the standard x86 calling convention which applies to all x86 compilers, 
not just GCC.

    Uwe
-- 
Uwe Doering         |  EscapeBox - Managed On-Demand UNIX Servers
gemini@geminix.org  |  http://www.escapebox.net
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic