You have to use MIPS 32 assembly language. describe in writing (or drawing) how stringlength.s…
You have to use MIPS 32 assembly language. describe in writing (or drawing) how stringlength.s interfaces with its internal procedure strlen, and how strlen calculates the length of a string This the code for stringlength.s: .dataAstr: .asciiz “this is our test string, it is 49 characters long”len: .word 0 .text .globl mainmain: addu $s7, $0, $ra # save return address in a global reg la $a0, Astr # pass address of the string jal strlen # calculate length sw $v0, len # store length .data .globl messagemessage: .asciiz “nThe length of the test string in the program is: ” .text li $v0, 4 # print_string (system call 4) la $a0, message # pass address syscall li $v0, 1 # print_int (system call 1) lw $a0, len # put value to print in $a0 syscall # # Usual stuff at the end of the main addu $ra, $0, $s7 # restore the return address jr $ra # return to the main program add $0, $0, $0 # nop # Procedure strlen accepts the address of a string, and returns the# length of that string. .text .globl strlenstrlen: # This procedure calculates the length of a string # presented as a null-terminated sequence of bytes # start of the string in $a0 # result returned in $v0 # all registers except $v0 and $a0 must be preserved # The algorithm is a loop which examines each byte # starting at the beginning of the string. # save register contents addi $sp, $sp, -12 # make room on stack sw $s0, 0($sp) # save $s0 sw $s1, 4($sp) # save $s1 sw $s2, 8($sp) # save $s2 # $s0 stores the current character # $s1 stores the length so far # $s2 stores address of current character li $s1, 0 # initializeloop: add $s2, $a0, $s1 # compute address lbu $s0, 0($s2) # fetch character beqz $s0, done # null byte is terminator addi $s1, $s1, 1 # increment length j loop # continuedone: move $v0, $s1 # put length in return register #restore registers lw $s0, 0($sp) # restore $s0 lw $s1, 4($sp) # restore $s1 lw $s2, 8($sp) # restore $s2 addi $sp, $sp, 12 # restore stack jr $ra # return May 13 2022 07:29 PM
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more