title: Moving Text program in Assembly Language
body: <p>I am trying to make a program in assembly language in which i want to move a text or character on the screen like a screensaver,i.e, at first it should move in forward as well as in downwards direction. When it hits the lower limit of the screen, it should start moving in forward and upward direction and vice versa.</p>
  
  <p>I have tried myself and i have been able to move the character in forward and downward direction at the same time. When the character hits lower limit of the screen, i want it to move in upward and forward direction but i can't seem to figure how to do it. </p>
  
  <p>I am using emu8086 assembler</p>
  
  <pre><code>.model small
  .data
  st1 db "O",13,10,'$'
  .code
  main proc
      mov AX,@data
      mov DS,AX 
  
      mov BL,0
      label1:
      mov AH,2H
      mov BH,0            ;goto-XY
      mov DH,BL
      mov DL,BL
      INT 10H
  
      mov AH,9H
      mov DX,offset st1      ;print
      INT 21H
  
      mov AH, 6H 
      mov AL, 0    
      mov BH, 7         ;clear screen 
      mov CX, 0
      mov DL, 79
      mov DH, 24
      int 10H
  
      ADD BL,1
  
      cmp DH,23           ;conditional jump
      jz label2
      loop label1 
  
      label2:
  
     ; mov AH,2H
     ; mov BH,0            ;goto-XY
     ; mov DH,BL
     ; mov DL,BL
     ; INT 10H
  
      mov AH,9H
      mov DX,offset st1      ;print
      INT 21H
  
      mov AH, 6H 
      mov AL, 0    
      mov BH, 7         ;clear screen 
      mov CX, 0
      mov DL, 79
      mov DH, 24
      int 10H
  
      SUB BL,1
      loop label2
  
      mov AH,4CH
      INT 21H
  end main 
  </code></pre>
  
  <p>At the end of each iteration of first loop, i am checking if 'DH' = 23 because lower limit of y-axis of my screen is 23. If lower limit of the screen is reached, it should jump to 'label2' but it does not jumps on to 'label2' which is obviously because i am not using 'cmp' statement correctly.
  Can anyone help me solve this problem ? </p>
  
  <p>Main thing that i want help with is what condition should i check in 'label1' to jump to 'label2'. </p>
  
  <p>PS. Just a beginner in  assembly language so if you suggest a solution, please keep it simple and easy to understand. 
  Here's what i have tried so far.</p>