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   
Text File  |  2009-03-27  |  674b  |  23 lines

  1.          .text
  2.          .globl __start
  3. __start:
  4.          la     $a1, string  # pointer
  5.          li     $t0, 0       # initialise
  6. loop:    lb     $t1 ($a1)    # get char
  7.          beqz   $t1, end     # end of string?
  8.          add    $t0, $t0,1   # increment length 
  9.          add    $a1, $a1, 1  # go onto next byte
  10.          j      loop
  11. end:     la     $a0, message
  12.          li     $v0, 4
  13.          syscall             # display message
  14.          move   $a0, $t0
  15.          li     $v0, 1
  16.          syscall             # show length
  17.          li     $v0, 10
  18.          syscall             # finish up
  19.  
  20.          .data
  21. message: .asciiz "Length is: "
  22. string:  .asciiz "Here is the string"
  23.