The jne jumps if the result of the previous instruction
(addc #lhi(1), &count+2), is non-zero.  It does not check
the contents of the lower word of 'count'.  It should jump
over the bar++ is either word of 'count' is non-zero.

NOTE: in my initial post, the word 'byte' should have been
'word'.

-Bill



On Tue, 17 Sep 2002 18:09:19 +0400, Dmitry wrote:

>Hm...
>the result will be like (optimization On , when Off, the asm is obvious):
>
>        add     #llo(1), &count
>        addc    #lhi(1), &count+2
>        jne     .L1
>        add     #llo(1), &bar
>        addc    #lhi(1), &bar+2
>.L1:
>       ret
>
>Is that wrong? ;)
>
>~d
>
>
>On Tue, 17 Sep 2002 08:51:20 -0500
>"Bill Knight" <[email protected]> wrote:
>
>> I'm a little hesitant in posting this...  I've been known to
>> be wrong on occasion (quite a few, if you ask my wife).
>> However, here goes anyway.  Given the following code fragment:
>> 
>> unsigned long count = 0;
>> unsigned long bar = 0;
>> 
>> void foo(void)
>> {
>>   if (++count == 0)
>>     bar++;
>> }
>> 
>> 'bar' will be increment once for each increment of 'count' for
>> as long as the upper byte of 'count' is zero.
>> 
>> I have followed this code at the assembly level using the
>> simulator.  It doesn't look like the fault is with the simulator.
>> The code appears to be checking ONLY if the upper byte of 'count'
>> is zero.
>> 
>> -Bill Knight
>> R O SoftWare
>> 
>> 
>> 
>> 
>> -------------------------------------------------------
>> Sponsored by: AMD - Your access to the experts on Hammer Technology! 
>> Open Source & Linux Developers, register now for the AMD Developer 
>> Symposium. Code: EX8664 http://www.developwithamd.com/developerlab
>> _______________________________________________
>> Mspgcc-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>> 
>> 
>
>
>/********************************************************************
>     ("`-''-/").___..--''"`-._     (\   Dimmy the Wild      UA1ACZ
>      `6_ 6  )   `-.  (     ).`-.__.`)  Enterprise Information Sys 
>      (_Y_.)'  ._   )  `._ `. ``-..-'   Nevsky prospekt,   20 / 44
>    _..`--'_..-_/  /--'_.' ,'           Saint Petersburg,   Russia
>   (il),-''  (li),'  ((!.-'             +7 (812)  3468202, 5585314
> ********************************************************************/
>
>
>-------------------------------------------------------
>Sponsored by: AMD - Your access to the experts on Hammer Technology! 
>Open Source & Linux Developers, register now for the AMD Developer 
>Symposium. Code: EX8664 http://www.developwithamd.com/developerlab
>_______________________________________________
>Mspgcc-users mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/mspgcc-users




Reply via email to