title: Assembly x86 Delay loop
body: <p>hi i made program that will rotate two symbols - \ and / but i dont know how to set cx counter in nested loops can someone give me advice or help me ? </p>
  
  <p>here is the code of that part </p>
  
  <pre><code>program:  
        mov ah, 0fh   ; function - get video mode
        int 10h
        push ax       ; save number of columns
        push bx       ; save page number
        mov ah, 0     ; function - set video mode
        int 10h
  
        mov al, 0003h     ;set video mode
        int 10h
  
        mov cx,10d  ; Outer loop counter how many symbols rotate
  
        mov bx,50d  ;   this is for delay loop
        OuterLoop:
        push cx
  
        mov ah,02h
        mov bh, 0        ;cursor set
        mov dh, 2
        mov dl, 10
        int 10h
  
        mov AH,0Ah
        mov al,"/"    symbol /
        mov bh,0
        mov cx,1
        int 10h
  
        mov cx,bx
        call Delay       ;delay loop
        sub bx,15d
  
        mov ah,02h
        mov bh, 0
        mov dh, 2            cursor set
        mov dl, 10
        int 10h
  
        mov AH,0Ah
        mov al,"\"             ;symbol \
        mov bh,0 
        mov cx,1
        int 10h
  
  
        mov cx,bx
        call Delay  ; another delay
        sub bx,10
  
  
        pop cx       ; Restore current CX
        loop OuterLoop
  
        jmp START     ; and after end it should jump to start where is menu with choices
  </code></pre>
  
  <p>it should work like this </p>
  
  <p>write /
  delay for example 10 sec
  write \
  delay 8 sec
  and jump to beginning and loop </p>
  
  <p>thanks for advices</p>
  
  <p>this is my delay procedure</p>
  
  <pre><code>Delay   PROC    NEAR                    ;
  
      push    ds                      ;
      push    si                      ;
      push    ax                      ;
      xor     ax, ax                  ;AX = 0
      mov     ds, ax                  ;DS = 0
      mov     si, 046Ch               ;
  t1:     mov     ax, [si]                ;
  t2:     cmp     ax, [si]                ;
      je      t2                      ;
      loop    t1                      ;
      pop     ax                      ;
      pop     si                      ;
      pop     ds                      ;
      ret                             ;
  
  Delay   ENDP                            ;
  </code></pre>
  
  <p>i am still working on this app but it is not working all i need is this steps to be made</p>
  
  <p>program :  start of loop
              \
              delay       delay 100 times
              /
              delay       delay 80 times
             loop
   and after every loop to decrease delay like this 100 times 80,60,40 and so on but i dont know where to put push and pop cx because my delay procedure is working with cx. i just set cx for example to 100 and it makes delay and so on. </p>