"LOOP" routine in Assembly

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View


Hi All

Google is NOT my friend here, or maybe I'm not searching correct - gets =
gazillions of hits on examples which I don't understand

I have the below routine that work 100%, but I want to add a "LOOP" to =
execute the FLASH routine i,e 5 times and then the FLASH_ODD routine 7 =
times before calling "AJMP FLASH" again to start from the beginning. =
Below is just a scale down version of my code, but If I can get this =
resolved, I will be able to implement it in my code

#################################################

        ORG 00H        ; Starts Here
FLASH:  CPL P1.0       ; Turn on/off the LED P1.0
        ACALL DELAY    ; call one second delay
        AJMP FLASH_ODD ; jump to FLASH_ODD

FLASH_ODD:  CPL P1.3   ; Turn on/off the LED P1.3
        ACALL DELAY    ; call one second delay
        AJMP FLASH     ; jump to FLASH

DELAY:     MOV R1,#0FFH
REPEAT:    MOV R2,#0FFH
   DJNZ R2,$
   DJNZ R1,REPEAT
   RET
   END20%

#################################################


Any suggestions will be greatly appreciated


Re: "LOOP" routine in Assembly


begin:  mov r3,#05
            mov r4,#07

loop1: lcall flash
            djnz r3,loop1

loop2:    lcall flash_odd
                djnz r4,loop2
                ljmp begin
  Hi All

  Google is NOT my friend here, or maybe I'm not searching correct - =
gets gazillions of hits on examples which I don't understand

  I have the below routine that work 100%, but I want to add a "LOOP" to =
execute the FLASH routine i,e 5 times and then the FLASH_ODD routine 7 =
times before calling "AJMP FLASH" again to start from the beginning. =
Below is just a scale down version of my code, but If I can get this =
resolved, I will be able to implement it in my code

  #################################################

          ORG 00H        ; Starts Here
  FLASH:  CPL P1.0       ; Turn on/off the LED P1.0
          ACALL DELAY    ; call one second delay
          AJMP FLASH_ODD ; jump to FLASH_ODD

  FLASH_ODD:  CPL P1.3   ; Turn on/off the LED P1.3
          ACALL DELAY    ; call one second delay
          AJMP FLASH     ; jump to FLASH

  DELAY:     MOV R1,#0FFH
  REPEAT:    MOV R2,#0FFH
     DJNZ R2,$
     DJNZ R1,REPEAT
     RET
     END20%

  #################################################


  Any suggestions will be greatly appreciated


Re: "LOOP" routine in Assembly


Thanx a million TTman - much appreciated - It's working !!!
  begin:  mov r3,#05
              mov r4,#07

  loop1: lcall flash
              djnz r3,loop1

  loop2:    lcall flash_odd
                  djnz r4,loop2
                  ljmp begin
    Hi All

    Google is NOT my friend here, or maybe I'm not searching correct - =
gets gazillions of hits on examples which I don't understand

    I have the below routine that work 100%, but I want to add a "LOOP" =
to execute the FLASH routine i,e 5 times and then the FLASH_ODD routine =
7 times before calling "AJMP FLASH" again to start from the beginning. =
Below is just a scale down version of my code, but If I can get this =
resolved, I will be able to implement it in my code

    #################################################

            ORG 00H        ; Starts Here
    FLASH:  CPL P1.0       ; Turn on/off the LED P1.0
            ACALL DELAY    ; call one second delay
            AJMP FLASH_ODD ; jump to FLASH_ODD

    FLASH_ODD:  CPL P1.3   ; Turn on/off the LED P1.3
            ACALL DELAY    ; call one second delay
            AJMP FLASH     ; jump to FLASH

    DELAY:     MOV R1,#0FFH
    REPEAT:    MOV R2,#0FFH
       DJNZ R2,$
       DJNZ R1,REPEAT
       RET
       END20%

    #################################################


    Any suggestions will be greatly appreciated


Re: "LOOP" routine in Assembly


HI All

At first I thought this is working , but when I added a huge delay to =
closely monitor the ports I notice that it ignores the repeat intervals, =
and after doing each of them sequentialy, it starts doing the routines =
randomly. Any suggestion why this will happen: It seems to ignore the =
results after the "MOV r?," commands , and do every LOOP? only once, and =
then after completing them once, starts to do them in random order

ORG 00H        ; Execution Starts Here

BEGIN:       MOV r3,#220%
             MOV r4,#2
             MOV r5,#2
             MOV r6,#2
             MOV r7,#3
20%
LOOP1:  LCALL ENGINE_1
        DJNZ r3,LOOP1
   20%
LOOP2:     LCALL EVENT_2
           DJNZ r4,LOOP2
     20%
LOOP3: LCALL EVENT_3
       DJNZ r5,LOOP3
     20%
LOOP4:     LCALL CLEAR_CHECK_1
           DJNZ r6,LOOP4
  20%
LOOP5: LCALL RESULT_PULSE_1
  DJNZ r7,LOOP5
  LJMP BEGIN

....... CODE

DELAY1:      MOV R1,#12020%
20%
 20%
REPEAT:    MOV R2,#0FFH
            DJNZ R2,$
           DJNZ R1,REPEAT
           RET
           END
  begin:  mov r3,#05
              mov r4,#07

  loop1: lcall flash
              djnz r3,loop1

  loop2:    lcall flash_odd
                  djnz r4,loop2
                  ljmp begin


Site Timeline