Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jul 2005 15:44:32 +0200
From:      Rink Springer <rink@stack.nl>
To:        Ludvig Strigeus <strigeus@gmail.com>
Cc:        hackers@freebsd.org, ed@fxq.nl
Subject:   Re: Problem with pic16l_setled
Message-ID:  <20050727134432.GA10142@stack.nl>
In-Reply-To: <4285cd45050727063146c054d4@mail.gmail.com>
References:  <4285cd45050727063146c054d4@mail.gmail.com>

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

--huq684BweRXVnRxX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi Ludvig,

* Ludvig Strigeus (strigeus@gmail.com) wrote:
> Hi!
>=20
> I see this code:
>=20
> +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
>=20
> 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 ?

--=20
Rink P.W. Springer                                - http://rink.nu
"God, root, what is difference?"                  - Pitr, Userfriendly

--huq684BweRXVnRxX
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (FreeBSD)

iD8DBQFC54/Ab3O60uztv/8RAhUJAKC+mqa+HBIpL7b1GGdU83BJ/2hlqgCgoDfm
bLoynyNAnMhVLOzn6FRh2cQ=
=7ilb
-----END PGP SIGNATURE-----

--huq684BweRXVnRxX--



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