How to get a substring of a string in Mips?
Just get a cross compiler, code it in C and get the output assembly. You can use the -S option if using gcc.
For example:
root@:~/stackoverflow# cat strstr.c
#include <string.h>
/*
* Find the first occurrence of find in s.
*/
char *
strstr(const char *s, const char *find)
{
char c, sc;
size_t len;
if ((c = *find++) != 0) {
len = strlen(find);
do {
do {
if ((sc = *s++) == 0)
return (NULL);
} while (sc != c);
} while (strncmp(s, find, len) != 0);
s--;
}
return (s);
}
root@:~/stackoverflow# gcc -S -mrnames strstr.c -o strstr.s
strstr.c: In function `strstr':
strstr.c:23: warning: return discards qualifiers from pointer target type
root@:~/stackoverflow#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With