home *** CD-ROM | disk | FTP | other *** search
/ cs.rhul.ac.uk / www.cs.rhul.ac.uk.zip / www.cs.rhul.ac.uk / pub / CS187 / ex2.a < prev    next >
Text File  |  2009-03-27  |  839b  |  30 lines

  1. # Second example of if statement - if...then...else
  2.          .text
  3.          .globl __start
  4. __start:
  5. # Setting up values
  6.          la     $t0, thislec
  7.          lw     $a0, ($t0)
  8. # Conditional statement follows
  9. # -----------------------------
  10.          bne    $a0, 33, else
  11.          la     $a0, happy
  12.          li     $v0, 4
  13.          syscall               # be happy
  14.          j      cont
  15. else:    la     $a0, sad
  16.          li     $v0, 4
  17.          syscall               # be sad
  18. # ----------------------------
  19. cont:    la     $a0, bye
  20.          li     $v0, 4
  21.          syscall               # say goodbdye         
  22.      li     $v0, 10
  23.          syscall               # finish up
  24.  
  25.          .data
  26. thislec: .word 32
  27. happy:   .asciiz "This is the last lecture - yaay!\n"
  28. sad:     .asciiz "Oh no, more lectures to come - boo!\n"
  29. bye:     .asciiz "Goodbye\n"
  30.