Converting C to MIPS(SPIM)

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2006
Posts: 2
Reputation: utopia14 is an unknown quantity at this point 
Solved Threads: 0
utopia14 utopia14 is offline Offline
Newbie Poster

Converting C to MIPS(SPIM)

 
0
  #1
Nov 27th, 2006
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);
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,625
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1495
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Converting C to MIPS(SPIM)

 
0
  #2
Nov 27th, 2006
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 275
Reputation: andor has a spectacular aura about andor has a spectacular aura about andor has a spectacular aura about 
Solved Threads: 29
andor's Avatar
andor andor is offline Offline
Posting Whiz in Training

Re: Converting C to MIPS(SPIM)

 
0
  #3
Dec 11th, 2006
With which part do you have problem?
If you want to win, you must not loose (Alan Ford)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC