Problem with pic16l_setled

Uwe Doering gemini at
Thu Jul 28 07:59:36 GMT 2005

Rink Springer wrote:
> * Ludvig Strigeus (strigeus at wrote:
>>I see this code:
>>+	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 Doering         |  EscapeBox - Managed On-Demand UNIX Servers
gemini at  |

More information about the freebsd-hackers mailing list