Question: Write a MIPS Assembly code where you are given a null-terminated string ($a0) and you need to calculate its length and store it in ($v0).

Write a MIPS Assembly code where you are given a null-terminated string ($a0) and you need to calculate its length and store it in ($v0). Basically you should count number of characters before reaching the character with value of 0. int strlen (str) {

int len = 0;

while (str[len] != 0) // 0 != '0'

len++; return len; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!