title: how does teq work in mips
body: <p>I compiled this code :  </p>
  
  <pre><code>int main()
  {
      int x;
      try
      {
          x=2/0;
      }
      catch (...)
      {
          x=1;
      }
      return 0;
  }
  </code></pre>
  
  <p>to mips and here's what I got :  </p>
  
  <pre><code>.file   1 "main.cpp"
  .section .mdebug.abi32
  .previous
  .nan    legacy
  .gnu_attribute 4, 1
  .abicalls
  .option pic0
  .text
  .align  2
  .globl  main
  .cfi_sections .eh_frame_entry
  $LFB6 = .
  .cfi_startproc
  .set    nomips16
  .set    nomicromips
  .ent    main
  .type   main, @function
  main:
  .frame  $fp,24,$31      # vars= 8, regs= 1/0, args= 0, gp= 8
  .mask   0x40000000,-4
  .fmask  0x00000000,0
  .set    noreorder
  .set    nomacro
  addiu   $sp,$sp,-24
  .cfi_def_cfa_offset 24
  sw  $fp,20($sp)
  .cfi_offset 30, -4
  move    $fp,$sp
  .cfi_def_cfa_register 30
  li  $2,2            # 0x2
  move    $3,$0
  teq $3,$0,7
  div $0,$2,$3
  mfhi    $2
  mflo    $2
  sw  $2,8($fp)
  move    $2,$0
  .cfi_epilogue_begin
  move    $sp,$fp
  .cfi_def_cfa_register 29
  lw  $fp,20($sp)
  addiu   $sp,$sp,24
  .cfi_restore 30
  .cfi_def_cfa_offset 0
  j   $31
  nop
  
  .set    macro
  .set    reorder
  .end    main
  .cfi_endproc
  $LFE6:
  .size   main, .-main
  .ident  "GCC: (Sourcery CodeBench Lite 2014.11-22) 4.9.1"
  </code></pre>
  
  <p>I want to ask particularly about the instruction <code>teq</code>, I know it means "trap if equal" so when the dividend is zero it will trap(and it is zero here).  </p>
  
  <p>What I don't understand is what happens after trap , I mean where is the catch block in this assembly file ? also when searching the web I see different things like coprocessor 0 ,exception code register ...etc.</p>
  
  <p>So what's happening here ?</p>