for loop in PIC18 assembly language

Discussion in 'Programmer's Corner' started by TheRekz, Oct 25, 2009.

  1. TheRekz

    Thread Starter New Member

    Oct 25, 2009
    13
    0
    I want to do a for loop which counts till the exit condition i > 50, is this right:

    Code ( (Unknown Language)):
    1.  
    2. COUNT EQU 0
    3.  
    4. LOOPING:  
    5.   MOVLW 50
    6.   CPFSGT COUNT
    7.   INCF COUNT 1
    8.   BRA END_LOOP
    9.   BRA LOOPING
    10.  
    11. END_LOOP:  
    12.  ; end of loop here
    13.  
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    This is how I would have done it a PIC16
    MainLoop:
    movlw 0x32 ;setting up loop counter 50 times
    movwf data1
    clrf data2 ;just clear data2
    Loop:
    incf data2,1 ;this is your loop task
    decfsz data1,f
    goto Loop
     
Loading...