2011-01-02 11 views
2

Wie bekomme ich einen Teilstring eines Strings in Mips?Teilstring in Mips

+0

Was Mips 'in Ihrer Frage ist? Es kann keine Mikroprozessor-Architektur sein, oder? – 9000

+0

Eigentlich versuche ich die "substr" -Funktion in C in Mips bei PCSpim zu konvertieren. –

Antwort

1

Holen Sie sich einen Cross-Compiler, codieren Sie ihn in C und holen Sie sich die Ausgabebaugruppe. Sie können die Option -S verwenden, wenn Sie gcc verwenden.

Zum Beispiel:

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 @: ~/# gcc -S Stackoverflow -mrnames strstr. c -o strstr.s

strstr.c: In function `strstr': 
    strstr.c:23: warning: return discards qualifiers from pointer target type 

root @: ~/# Stackoverflow