Problem with pic16l_setled

Rink Springer rink at stack.nl
Wed Jul 27 13:44:35 GMT 2005


Hi Ludvig,

* Ludvig Strigeus (strigeus at gmail.com) wrote:
> Hi!
> 
> 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).
You see, in C, I call the function like this (for example):

	void pic16l_setled(unsigned int val);
	pic16l_setled (0x1234);

And it gets assembled to:

	pushl	$0x1234
	call	pic16l_setled

But it should be assembled to:

	pushl	$0x1234
	call	pic16l_setled
	add	$4,%esp			/* ditch the parameter */

I don't know why it doesn't do this :(

> +ENTRY(pic16l_reboot)
> +       pushl   $0x01
> +       pushl   $0x02
> +       pushl   $0x20
> +       call    pic16l_setbyte
> +       ret
>
> You're forgetting to adjust the stack here.. you should add 12 to esp
> before returning.
> Same thing in pic16l_poweroff.

Indeed, very correct! Since there functions plainly reboot / halt, I
never noticed this, but you are indeed correct. I'll fix it in a new
patchset.

> I've never done any FBSD dev, so i could be wrong...but it's worth a try.

Thank you very much for your time! I've CC-ed this discussion to
hackers@, perhaps someone knows more about this ?

-- 
Rink P.W. Springer                                - http://rink.nu
"God, root, what is difference?"                  - Pitr, Userfriendly
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20050727/e218ecd0/attachment.bin


More information about the freebsd-hackers mailing list