home *** CD-ROM | disk | FTP | other *** search
- # Second example of if statement - if...then...else
- .text
- .globl __start
- __start:
- # Setting up values
- la $t0, thislec
- lw $a0, ($t0)
- # Conditional statement follows
- # -----------------------------
- bne $a0, 33, else
- la $a0, happy
- li $v0, 4
- syscall # be happy
- j cont
- else: la $a0, sad
- li $v0, 4
- syscall # be sad
- # ----------------------------
- cont: la $a0, bye
- li $v0, 4
- syscall # say goodbdye
- li $v0, 10
- syscall # finish up
-
- .data
- thislec: .word 32
- happy: .asciiz "This is the last lecture - yaay!\n"
- sad: .asciiz "Oh no, more lectures to come - boo!\n"
- bye: .asciiz "Goodbye\n"
-