Hi,

> Hello, I am fighting with 16f690 processor. I have two INT variables and  
> add them together. SDCC generates following code:

Annotated for clarity, low byte in [0], high byte in [1]:

> ;     .line   349; "main.c"   gYfilter = gYfilter + gYrotation;
>       BANKSEL _gYrotation
>       MOVF    _gYrotation,W           ; W = gYrot[0]
>       BANKSEL _gYfilter
>       ADDWF   _gYfilter,F             ; gYfil[0] = gYfil[0] + gYrot[0]
>       BANKSEL _gYrotation
>       MOVF    (_gYrotation + 1),W     ; W = gYrot[1]
>       BTFSC   STATUS,0                ; skip if no CARRY
>       INCF    (_gYrotation + 1),W     ; inc W to honor CARRY
>       BTFSC   STATUS,2                ; skip if not ZERO
>       GOTO    _00004_DS_              ; if W is zero, nothing to do
>       BANKSEL _gYfilter
>       ADDWF   (_gYfilter + 1),F       ; otherwise, gYfil[1]+=gYrot[1]+CY
>
> _00004_DS_:

Looks good to me.

> Is it correct ? if both low bytes are 0x00, first btfsc skips and the
> second skips as well. so there will be no addition at all.

The second BTFSC checks the ZERO flag, which is set iff  
`gYrotation[1]+CARRY == 0'. In this case, the high byte of gYfilter in  
fact does not require any change.

Do you observe erroneous behaviour exactly when this code fragment is  
executed?!? What do you observe? What do you expect? Could you publish the  
failing/faulty source code?

Best regards,
Raphael

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to