title: MIPS function syscall printing random number/memory address instead of parameter
body: <p>I'm new to MIPS and I'm trying to write a very basic function that takes 4 numbers (so 4 parameters) and adds them together. I'm doing it so 3 of the numbers are <strong>hard-coded</strong> in memory and the 4th number (x) is received by user input.</p>
  <p>Right now I'm just trying to print all 4 numbers once I'm inside the function (just to verify that they were all passed in correctly), but instead it's printing a random long number (the address?) and I can't tell what's going on.</p>
  <pre><code>.data
  
  # initialize variables
  num1:
      .word 10
  num2:
      .word 15
  num3: 
      .word -7
      
      
  x:
      .word 0
  
  
  input_msg: 
      .asciiz &quot;Enter a number for x :&quot;
  
  
  .text
          
  .globl main
  
  main:
  
      addiu $sp, $sp, -4  
  
      #get value of x from user input
      la $a0, input_msg
      jal getInteger
      move $s0, $v0  #returned value goes into $s0 (this all works correctly)
  
      #parameters for function call
      move $a0, $s0
      la $a1, num1
      la $a2, num2
      la $a3, num3
      jal add_nums
  
      addiu $sp, $sp, 4
  
      # end of program
      li $v0, 10
      syscall
  
  add_nums:
      #allocate stack space
      addiu $sp, $sp, -16
  
      li $v0, 1
      syscall
  
      li $v0, 1
      syscall
  
      li $v0, 1
      syscall
  
      li $v0, 1
      syscall
  </code></pre>
  <p>It prints &quot;111111268500992&quot; which I assume is arbitrary, but what's really going on here? I thought I understood function calls but this has me perplexed.</p>