title: Converting Assembly Language to Python Code
body: <p>I am trying to convert assembly language to Python.  I'm trying to follow the assembly code as literally as possible when I do this. I know this particular code will require nested conditional statements. I'm using a,b,c,d as memory locations.</p>
  
  <p>Here is the assembly language:</p>
  
  <pre><code>    0   IN a
      1   LOAD d
      2   COMPARE a
      3   JUMPLT 6
      4   JUMPEQ 6
      5   JUMPGT 12
      6   OUT c 
      7   LOAD a
      8   ADD b
      9   STORE c
      10  DECREMENT d
      11  JUMP 20
      12  DECREMENT c
      13  LOAD a
      14  COMPARE c
      15  JUMPLT 19
      16  JUMPEQ 19
      17  INCREMENT d   
      18  CLEAR c             
      19  OUT d
      20  OUT b
      21  HALT
  </code></pre>
  
  <p>This is my literal translation of the code into Python. </p>
  
  <pre><code>      a = input()
  
        if a&lt;=d:
          print c
          c = a+b
          d = d-1
          print b  
  
        else:
          c = c-1
          if c&lt;=a:
            print d
            print b
  
          else:
            d=d+1
            c=0
            print d
            print b
  </code></pre>
  
  <p>I see that print d and print b are included in the if and else nested statements so if I'm not doing a literal translation of the code, maybe it should look like this?</p>
  
  <pre><code>      a = input()
  
        if a&lt;=d:
          print c
          c = a+b
          d = d-1
          print b 
  
        else:
          c = c-1
          print d
          print b
  
          if c&gt;a:
            d=d+1
            c=0
  </code></pre>
  
  <p>And my final questions: are either of these translations correct?  They don't evaluate the same way.  Also are there better ways to do this translation?</p>
  
  <p>Any other tips or rules to keep in mind about these conversions would be welcome. </p>
  
  <p>Thanks in advance for your help.</p>