• PicŪ Basic


  • Saving code by not using For-Next

    by Tim Box

    A sure fire way to use up valuable code space is use for next loop's! While they may look short and compact in the Editor the extra checks required to manage them properly in asm rob the PICŪ of it's valuable code space.

    Far better to use REPEAT-UNTIL or WHILE-WEND.

    An example

    Code:
    For a = 0 to 100
    'code here
    Next
    uses 7 bytes of code

    Code:
    Clear a
    Repeat
    'code here
    Inc a 
    Until a = 100
    uses 6 bytes

    Code:
    For a = 100 to 10 step - 10
    'code here
    Next
    'code here
    uses 10 bytes

    Code:
    a = 100
    Repeat
    'code here
    a = a - 10 
    Until a <= 10
    Uses 10 bytes