could be...
now play with the a < x value, and look what happen to your code size.. interesting eh?Code:DEFINE OSC 20 TRISB.0 = 0 PORTB = 0 pauseus 0 ' do nothing good but include PAUSEUS?C macro TRISB.0 = 0 PORTB = 0 start: asm CHK?RP PORTB local a=0 while a<16 BSF PORTB,0 nop PAUSEUS?C 12 BCF PORTB,0 nop PAUSEUS?C 12 a+=1 endw endasm pause 100 goto start
Now compare the code size of
copy and pasted 16 times, with the one generated with my solution... mmm interestingCode:PORTB.0 = 1 @ nop Pauseus 12 PORTB.0 = 0 @ nop PAUSEUS 12
Sometime MPASM directive are really handy!
EDIT: you could also use
If you don't like the PAUSE?C, BSF, BCF option... both generate the same code.Code:@ local a=0 @ while a<16 PORTB.0=1 @ nop PAUSEUS 12 PORTB.0=0 @ nop PAUSEUS 12 @a+=1 @ endw





Bookmarks