avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Setting pin to high in function instead of main, inst


From: Johannes Bauer
Subject: Re: [avr-gcc-list] Setting pin to high in function instead of main, instructions in main never run?
Date: Thu, 01 Mar 2012 16:45:10 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15

On 01.03.2012 16:30, David Kelly wrote:
> 
> On Mar 1, 2012, at 9:10 AM, Richard Zetterberg wrote:
> 
>> int main(void)
>> {
>>        DDRB |= (1 << PB0);
>>  84: 20 9a           sbi     0x04, 0 ; 4
>>        turn_on_pb();
>>  86: 0e 94 40 00     call    0x80    ; 0x80 <turn_on_pb>
>>  8a: ff cf           rjmp    .-2             ; 0x8a <main+0x6>
>>
>> 0000008c <_exit>:
>>  8c: f8 94           cli
>>
>> 0000008e <__stop_program>:
>>  8e: ff cf           rjmp    .-2             ; 0x8e <__stop_program>
> 
> Pardon me for tuning in late but since when did main() start ending with an 
> "rjmp .-2" infinite loop as shown at 0x8a above? Is supposed to ret to caller 
> which then calls _exit or perhaps calls something else. But my point is that 
> int main() is a function that is supposed to return to caller.

Because his code looks like this:

int main(void)
{
        DDRB |= (1 << PB0);
        turn_on_pb();
        for (;;) {
        }
        return 0;
}

The for(;;) is the interesting part ;-)

Best regards,
Joe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]