Re: Problem with pic16l_setled

From: Rink Springer (rink_at_stack.nl)
Date: 07/27/05

  • Next message: Norbert Koch: "RE: Problem with pic16l_setled"
    Date: Wed, 27 Jul 2005 15:44:32 +0200
    To: Ludvig Strigeus <strigeus@gmail.com>
    
    
    

    Hi Ludvig,

    * Ludvig Strigeus (strigeus@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 message: Norbert Koch: "RE: Problem with pic16l_setled"