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);

Edited by happygeek: fixed formatting

11 Years
Discussion Span
Last Post by andor

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.