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

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