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 >
Wrap
Text File
|
2009-03-27
|
884b
|
31 lines
# Third example of conditional statement - if...then...else
# using a positive Boolean condition
.text
.globl __start
__start:
# Setting up values
la $t0, thislec
lw $a0, ($t0)
# Conditional statement follows
# -----------------------------
beq $a0, 33, then
la $a0, sad
li $v0, 4
syscall # be sad
j cont
then: la $a0, happy
li $v0, 4
syscall # be happy
# ----------------------------
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"