Hey guys I know little of C (specializing in JAVA) and my data structures course asked that I transfer this into MIPS using $a and $v registers... any help would be awesome!

#include <stdlib.h>
void *(memset)(void *s, int c, size_t n) {
    const unsigned char uc = c;
    unsigned char *su;
    for (su = s; 0 < n; ++su, --n) {
        *su = uc;
    }
    return s;
}    
void *(a_memmove)(void *dest, const void *src, size_t n) {
    char *sc1;
    const char *sc2;
    sc1 = dest;
    sc2 = src;
    if (sc2 < sc1 && sc1 < sc2 + n) {
        for (sc1 += n, sc2 += n; 0 < n; --n) {
            *--sc1 = *--sc2;
        }
    } else {
        for (; 0 < n; --n) {
            *sc1++ = *sc2++;
        }
    }
    return (dest);
}
char *(a_strcat)(char *dest, const char *src, size_t n) {
    char *s;
    for (s = dest; *s != '\0'; ++s)
        ;
    for (; 0 < n && *src != '\0'; --n) {
        *s++ = *src++;
    }
    *s = '\0';
    return (dest);
}

Recommended Answers

1st: please use code tags when posting code. If you don't know how to do that you can read the links in my signature.

2nd. Many compilers will produce assembly language printouts of the c code. Check your c compiler to see if it has options to do that. …

Jump to Post

All 2 Replies

1st: please use code tags when posting code. If you don't know how to do that you can read the links in my signature.

2nd. Many compilers will produce assembly language printouts of the c code. Check your c compiler to see if it has options to do that. If not, I don't know MIPS assembly, so I can't help you.

With which part do you have problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.