home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
cs.rhul.ac.uk
/
www.cs.rhul.ac.uk.zip
/
www.cs.rhul.ac.uk
/
pub
/
CS187
/
ex6.a
< prev
Wrap
Text File
|
2009-03-27
|
674b
|
23 lines
.text
.globl __start
__start:
la $a1, string # pointer
li $t0, 0 # initialise
loop: lb $t1 ($a1) # get char
beqz $t1, end # end of string?
add $t0, $t0,1 # increment length
add $a1, $a1, 1 # go onto next byte
j loop
end: la $a0, message
li $v0, 4
syscall # display message
move $a0, $t0
li $v0, 1
syscall # show length
li $v0, 10
syscall # finish up
.data
message: .asciiz "Length is: "
string: .asciiz "Here is the string"