title: Translating Python code to assembly
body: <p>In this current example above which I wrote, I used 80 as n. My output is n = 91, and count = 42. This is also known as McCarthy 91. However I would now like to use this code within assembly language(MIPS). Does anyone have any tips on how this might be done? I have never dealt with building a recursion type program in MIPS. Below I have supplied my working python code, and my assembly code with comments which is in the process of being wrote below the python code. Any tips/help will certainly be appreciate with the assembly code.</p>
  
  <p>Python code:</p>
  
  <pre><code>   def mcc91(n):
          global count
          count +=1
          if n &gt; 100:
              return n -10
          else:
              return mcc91 (mcc91(n + 11))
  
  
      def main():
          print mcc91(80)
          print count
  
      main()
  </code></pre>
  
  <p>MIPS PROGRAM</p>
  
  <pre><code>.data
      p1:
          .asciiz "What is integer n? "
      ans1:
          .asciiz "\nn is "
      ans2:
          .asciiz "\nCount is "
  
  
          .text
          .globl main
  
      main:
          li $v0, 4       # system call code for print_str
          la $a0, p1      # address of string to print
          syscall         # print the first prompt
  
          li $v0, 5       # system call code for read_int
          syscall         # read the first integer
          move    $t1, $v0    # and store it 'till later
  
          li $t9, 0       #tracks count
  
      loop1:
          bgt $t1, 100, target1
          add $t1, $t1, 11    #adds 11 when under 100
          add $t9, $t9, 1     #add 1 to count
          Loop1(loop1     #cluless how to do this
  
      target1:
          sub $t1, $t1, 10    #subtracts 10 when over 100
          add $t9, $t9, 1     #add 1 to count
          #j done         #cluless here also(how many stacks in is it? If 0, jump to done)
  
      done:
      #THIS PRINTS N
          li $v0, 4       # system call code for print_str
          la $a0, ans1        #address of string to print
          syscall         # print the answer identifying string
  
          li $v0, 1       # system call code for print_int
          move $a0, xxxxx     # integer to print (sum)
          syscall         # print it
  
      #THIS PRINTS Count
          li $v0, 4       # system call code for print_str
          la $a0, ans2        # address of string to print
          syscall         # print the answer identifying string
  
          li $v0, 1       # system call code for print_int
          move $a0, xxxxx     # integer to print (difference)
          syscall         # print it
  
  
          jr $ra          # return from this program to the system
  </code></pre>