[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Is it possible to implement...
From: |
E. Weddington |
Subject: |
Re: [avr-gcc-list] Is it possible to implement... |
Date: |
Fri, 03 Jan 2003 10:33:10 -0700 |
On 30 Dec 2002 at 21:59, Rune Christensen wrote:
> Hello
>
> Is it possible to implement the following code in avr-gcc not using
> assembler
>
> if (carry(csumlo += data))
> {
> if (carry(++csumhi))
> {
> csumlo++;
> }
> }
>
> Now it's implemented as
>
> csumlo += data;
> if (csumlo < data)
> {
> if (++csumhi==0)
> {
> csumlo++;
> }
> }
>
> But I want to optimize it with the carry-bit
>
> Thanks in advance
>
> Rune Christensen
Well you can access the status register in C by using SREG. SREG is
defined in the processor IO header files (like iom128.h). The carry
bit is bit 0 in SREG, so you should be able to implement an algorithm
using this.
Eric
avr-gcc-list at http://avr1.org