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 >
Wrap
Text File
|
2009-03-27
|
839b
|
30 lines
# 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"