Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

!!! Please read the entire question and do not copy off google, I have already l

ID: 3869084 • Letter: #

Question

!!! Please read the entire question and do not copy off google, I have already looked and am searching for a unique answer to help me learn this. Thank you for your help in advance. !!!

Write a program in MIPS assembly language that asks the user to input a string (or no more than 50 characters). Your program should then output the length of the string. The string length should be determined using a separate function strlen that will accept the address of the string and return its length.

For the purposes of this exercise, the length of a string will be defined as the number of non-null and non-newline characters until either the null character (ASCII 0) or the newline character (ASCII 10) is encountered.

Thank you! Please include some form of comments or explanation, as this is a beginners class and assembly language is hard to follow without them. And again, please do not copy and paste from here or google. I'm looking for a unique solution.

Explanation / Answer

MIPS GCC 5.4 code

$LFB0 = .

main:

addiu $sp,$sp,-88

sw $31,84($sp)

sw $fp,80($sp)

move $fp,$sp

addiu $2,$fp,28

move $5,$2

lui $2,%hi($LC0)

addiu $4,$2,%lo($LC0)

jal scanf

nop

addiu $2,$fp,28

move $4,$2

jal strlen

nop

sw $2,24($fp)

lw $5,24($fp)

lui $2,%hi($LC1)

addiu $4,$2,%lo($LC1)

jal printf

nop

move $2,$0

move $sp,$fp

lw $31,84($sp)

lw $fp,80($sp)

addiu $sp,$sp,88

j $31

nop