title: Can I use $PC in MIPS
body: <p>As far as I know, program counter, $PC is hidden from users. It isn't one of the 32 registers. </p>
  
  <p>I want to do the following, instead of using jal</p>
  
  <pre><code>$ra &lt;= PC + 4
  j my_function
  # instead of jal my_function
  </code></pre>
  
  <p>Is is possible to do this? I know JAIL is a macro.</p>
  
  <p>How can I jump to a function without using JAL and able to return to the next instruction of the caller? Thanks.</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <blockquote>
    <p>One supported method of "discovering" the PC in code is to use JAL
    with a zero offset (to jump/link to the next instruction), then read
    the PC out of R31.</p>
  </blockquote>
  
  <p>Attempt:</p>
  
  <pre><code>..statements before jump...
  jal $0
  addi $t3, $ra, 4
  ..statements when function returns..
  </code></pre>
  
  <p>I end up in infinite loop.</p>