943,923 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 7105
  • Assembly RSS
Nov 27th, 2006
0

Converting C to MIPS(SPIM)

Expand Post »
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);
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
utopia14 is offline Offline
2 posts
since Nov 2006
Nov 27th, 2006
0

Re: Converting C to MIPS(SPIM)

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005
Dec 11th, 2006
0

Re: Converting C to MIPS(SPIM)

With which part do you have problem?
Reputation Points: 251
Solved Threads: 29
Posting Whiz in Training
andor is offline Offline
274 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: sort program assembly
Next Thread in Assembly Forum Timeline: First Timer and trying to learn the basics (Please help me ASAP)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC