title: Assembly - Draw A Circle
body: <p>I am now trying to draw a circle in Assembly but for some reason it doesn't work, DOSBox freezes and I can't seem to understand why. Moreover, the circle doesn't appear on the screen. I found most of the code online and I am trying to use it and understand what it does but I can't seem to find any mistakes here.  </p>
  
  <p>Here is the code:</p>
  
  <pre><code>player1disccolor db 0Eh
  Player1Disc:
      push 0a000h 
      pop es                   
      mov dx, 20               
      mov di, 20               
      mov al, [player1disccolor]               
      mov bx, 30                
      call Player1Disc       
      mov ah, 0 
      int 10h                     
      mov bp,0                 
      mov si,bx                
  
  Disc1:                
      call Set8pixels                             
      sub  bx,bp               
      inc  bp                   
      sub  bx,bp                
      jg   Disc2                  
      add  bx,si                
      dec  si                   
      add  bx,si               
  
  Disc2:                
      cmp si,bp              
      jae Disc1                  
      ret 
  
  Set8pixels:           
      call Set4pixels             
  
  Set4pixels:           
      xchg bp,si               
      call Set2pixels             
  
  Set2pixels:
      neg si 
      push di 
      add di,si 
      add di,dx 
      mov [es:[di+bp]],al 
      sub di,bp 
      stosb 
      pop di 
      ret 
  </code></pre>
  
  <p>Thanks to anyone who helps. </p>