## LSU EE 3755 -- Spring 2002 -- Computer Organization # ## Example used in class 19 April 2002. .data SAMPLE: .asciiz "This is our sample string." msg: .ascii "The length of the string,\n\t \"%/a2/s\",\n is %/v1/d\n" .asciiz "Have a nice day.\n" .text .globl __start __start: la $a0, SAMPLE jalr strlen nop addi $v1, $v0, 0 la $a2, SAMPLE addi $v0, $0, 11 la $a0, msg syscall addi $v0, $0, 10 syscall strlen: ## Register Usage # # $a0: Address of first character of string. # $v0: Return value, the length of the string. # # addi $v0, $a0, 1 LOOP: lbu $t0, 0($a0) bne $t0, $0 LOOP addi $a0, $a0, 1 jr $ra sub $v0, $a0, $v0 ####