title: MIPS "main" declared global label but not defined
body: <p>This is a sample program for MIPS. I am using MARS 4.5, and I had enabled settings -> Initialize Program Counter to global "main" if defined. However, when i tried to assemble, it said that on the line .globl main, "main" declared global label but not defined. I am not sure how to fix it?</p>
  
  <p>-------Macro definition-----</p>
  
  <pre><code>    # Macro : print_str
      # Usage: print_str(&lt;address of the string&gt;)
      .macro print_str($arg)
      li  $v0, 4     # System call code for print_str  
      la  $a0, $arg   # Address of the string to print
      syscall            # Print the string        
      .end_macro
  
      # Macro : print_int
      # Usage: print_int(&lt;val&gt;)
      .macro print_int($arg)
      li  $v0, 1     # System call code for print_int
      li  $a0, $arg  # Integer to print
      syscall            # Print the integer
      .end_macro
  
      # Macro : exit
      # Usage: exit
      .macro exit
      li  $v0, 10 
      syscall
      .end_macro
  </code></pre>
  
  <p>------Data Segment Definition----</p>
  
  <pre><code>.data
  str: .asciiz "Enter="
  </code></pre>
  
  <p>----- Code Segment Definition ----</p>
  
  <p><code>.text
  .globl main
  Main:     print_str(str)
            print_int(54)
              exit</code></p>