title: Drawing on MIPS. Runtime error
body: <p>have a problem with the following code. I wrote a code for drawig a quater circle on a MARS assembler. But there is an error occurring. The program itself draws the quater circle but in the end there is an error, because of it I cannot use a loop for this procedure, the code is below</p>
  
  <pre><code>.data
      DISPLAY: .space 65536    
      DISPLAYWIDTH: .word 128
      DISPLAYHEIGHT: .word 128
  
  .text
  
  j main
  
  set_pixel_color:
  
      mulu $t0 $a1 $s0 
      add $t0 $t0 $a0
      mul $t0 $t0 4
  
      la $t2 DISPLAY
      add $t2 $t2 $t0
  
      sw $a2 ($t2)
      jr $ra          
  
  quater_circle:              
      add $a1 $0 0
      add $a0 $0 0
      lw $a2 RED  
  
          loop2:
                   jal set_pixel_color
               add $a0 $a0 1
               mulu $t3 $a0 $a0
               mulu $t4 $a1 $a1 
               add $t3 $t3 $t4
               mulu $t4 $a3 $a3
  
               ble $t3 $t4 loop2                       
               add $a0 $0 $0
               add $a1 $a1 1
  
               ble $a1 $a3 loop2
               jr $ra 
  
  .data
      RED: .word  0xff0000
      GREEN: .word    0x00ff00
      BLUE: .word     0x0000ff 
  .text
  
  main:
      lw $s0, DISPLAYWIDTH    # s0 holds MAX x
      lw $s1, DISPLAYHEIGHT   # s1 holds MAX y
      li $a3 1   
      lw $a2 BLUE
      add $a0 $0 $0
      add $a1 $0 $0
           loop:
               jal set_pixel_color
               add $a0 $a0 1
               ble $a0 127 loop
               add $a0 $0 $0 
               add $a1 $a1 1
               ble $a1 127 loop  
           draw:
                jal quater_circle
                add $a3 $a3 1
                ble $a3 128 draw
  </code></pre>
  
  <p>It ends up with the drawn red quater circle with the blue backround, however it terminates in the end of the procedure, and I cannot use a <code>draw</code> procedure. Can you help me please?</p>