#99 if( countup != 0xFFFFffff) on mcs51

open
nobody
None
1
2005-03-04
2005-03-04
No

could be shorter for mcs51, compiling:

volatile unsigned long countup;

void tst(void)
{
if( countup != 0xFFFFffff)
countup++;
}

gives:

mov a,_countup
cjne a,#0xFF,00106$
mov a,(_countup + 1)
cjne a,#0xFF,00106$
mov a,(_countup + 2)
cjne a,#0xFF,00106$
mov a,(_countup + 3)
cjne a,#0xFF,00106$

when it could be (if all bytes are created equal)

mov a,#0xff
cjne a,_countup,00106$
cjne a,(_countup+1),00106$
cjne a,(_countup+2),00106$
cjne a,(_countup+3),00106$

Discussion

  • Hubert Sack

    Hubert Sack - 2005-03-09

    Logged In: YES
    user_id=1160854

    I wrote the solution for this RFE. My solution works even if
    only some bytes are equal and generates optimal code
    therefore

     
  • Maarten Brock

    Maarten Brock - 2005-03-09

    Logged In: YES
    user_id=888171

    Can you upload this solution? F.E. the diff with current
    versions.

     
  • Frieder Ferlemann

    Logged In: YES
    user_id=589052

    it seems only the creator of a feature request can attach a
    file to it.

    I'm attaching it here on Hubert's behalf.

     
  • Maarten Brock

    Maarten Brock - 2005-03-10

    Logged In: YES
    user_id=888171

    That's right I think. Only the creator (and project
    developers/administrators) can upload. Thanks anyway.

     
  • Frieder Ferlemann

    Logged In: YES
    user_id=589052

    I'm attaching a vastly improved version of the patch on
    Hubert's behalf.

    To see the optimizations done by the patch have a look into
    test.rst.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks