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

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

Re: [avr-gcc-list] Strange thing...


From: Brian Sidebotham
Subject: Re: [avr-gcc-list] Strange thing...
Date: Mon, 22 Sep 2003 15:31:58 +0100

Hi John,

 The adiw command can only add a maximum of 63.

 From the instruction set manual:

 Adds an immediate value (0-63) to a register pair and places the result in the
register pair. This instruction operates on the upper four register pairs, and
is well suited for operations on the pointer registers.

It's a bit more complicated to use than you first think. Just do a <64 check. If
it isn't then subtract it, and add 63 to the register pair. Keep going until the
variable is less than 64. Then just add the remainder to the register pair.

Either way, have a look at the instruction set specifications for further info.

Hope this helps,
Brian Sidebotham.

----- Original Message -----
From: "John Yannakopoulos" <address@hidden>
To: "AVR GCC Mailing List" <address@hidden>
Sent: Monday, September 22, 2003 2:15 PM
Subject: [avr-gcc-list] Strange thing...


|
| Hi all.
|
| I'm trying to measure the execution time (in CPU cycles) of a simple for
| loop. For my settings refer to the PS section of my e-mail. Imagine the
| following situ:
|
| unsigned short value = 62;
| unsigned short i;
|
| start_timer();
| for (i = 0; i < value; i++) ;
| stop_timer();
|
| The loop in AVR assembly, is shown below:
|
| mov ...
| mov ...
|
| loop:
| adiw ...
| cpi  ...
| cpc  ...
| brlo loop
|
| When 'value' equals to 62, I get a time value of 190 cycles. When I
| set 'value' to 64, the time measured is 16 cycles! What am I doing wrong?
|
| Regards,
|
| --
| Ioannis Yannakopoulos.
|
| PS> My settings are: ATMEL AVR 8535 (i.e. approx. 4MHz CPU clock), 'avr-gcc'
| on a linux machine, 'uisp' for mC programming. I'm using the timer 0 of
| the mC (without prescaling) and I'm counting overflows + remainder clock
| ticks (in interrupt mode). Thus, the final time measurement is as follows:
| Time = (overflows << 8) + remainder.
|
|
| _______________________________________________
| avr-gcc-list mailing list
| address@hidden
| http://www.avr1.org/mailman/listinfo/avr-gcc-list





reply via email to

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