如何在Mips中获取字符串的子字符串?
答案 0 :(得分:1)
只需获得一个交叉编译器,用C编写代码并获取输出程序集。如果使用gcc,则可以使用-S选项。
例如:
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
根@:〜/计算器#