[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Compile Error
From: |
Galen Seitz |
Subject: |
Re: [avr-gcc-list] Compile Error |
Date: |
Sun, 23 Jan 2005 09:46:33 -0800 |
lgp <address@hidden> wrote:
> Source file is:
>
> int main( void ){
> unsigned char a;
> a++;
> while(1);
> }
>
>
> List file is:
>
> int main( void ){
> 8e: ce e5 ldi r28, 0x5E ; 94
> 90: d4 e0 ldi r29, 0x04 ; 4
> 92: de bf out 0x3e, r29 ; 62
> 94: cd bf out 0x3d, r28 ; 61
> unsigned char a;
> a++;
> 96: 89 81 ldd r24, Y+1 ; 0x01
> 98: 8f 5f subi r24, 0xFF ; 255
> 9a: 89 83 std Y+1, r24 ; 0x01
> while(1);
> 9c: ff cf rjmp .-2 ; 0x9c
>
>
>
>
> Is it right??
>
> a++;
> 96: 89 81 ldd r24, Y+1 ; 0x01
> >> 98: 8f 5f subi r24, 0xFF ; 255 ??????
> 9a: 89 83 std Y+1, r24 ; 0x01
>
At first glance it looks correct to me. 0xff is a -1 in two's complement
form. Therefore:
r24 - 0xff = r24 - -1 = r24 + 1
If you look at the Atmel doc for the AVR instruction set, you will see
that there is no 8 bit Add Immediate. SUBI and Add Immediate are
equivalent.
galen