[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] How to reserve registers
From: |
Paulo Marques |
Subject: |
Re: [avr-gcc-list] How to reserve registers |
Date: |
Wed, 04 Jan 2012 14:51:39 +0000 |
User-agent: |
Thunderbird 2.0.0.23 (X11/20090817) |
Georg-Johann Lay wrote:
> Paulo Marques wrote:
>
>> push r0
>> in r0, SREG
>> push r1
>> eor r1, r1
>> push r2
>>
>> sec
> ^^^
> Superfluous
>
>> in r2, GPIOR0
>> adc r2, r1
>
> Why using ADC? AVR has INC (increment by 1) instruction that works with any
> register.
INC doesn't set the carry bit...
>> out GPIOR0, r2
>> in r2, GPIOR1
>> adc r2, r1
>
> ditto
This is propagating the carry from the previous add, doing a multibyte
increment.
>> out GPIOR1, r2
>> in r2, GPIOR2
>> adc r2, r1
>
> ditto
ditto :)
>> out GPIOR2, r2
>> lds r2, high_counter_byte
>> adc r2, r1
>
> ditto
ditto :)
>> sts high_counter_byte, r2
>>
>> pop r2
>> pop r1
>> out SREG, r0
>> pop r0
>> reti
--
Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com
"This version has many new and good features. Sadly, the good ones are
not new and the new ones are not good."
Re: [avr-gcc-list] How to reserve registers, Volker Kuhlmann, 2012/01/03