convert c programm to mips assembly

This is a discussion on convert c programm to mips assembly within the Tech Board forums, part of the Community Boards category; i'd like some help cause i'm new to assembly language i have this program in c and i have to ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    4

    convert c programm to mips assembly

    i'd like some help cause i'm new to assembly language
    i have this program in c and i have to convert it to assembly language

    Code:
    int R[100];
    char S[100,100];
    
    int process(int rows) {
    int i;
    
    for (i=0;i<rows;i++) {
    tmp=strlen(&S[i])):
    R[i]=tmp;
    if (tmp==0) return i;
    }
    
    return i;
    }
    this function processes a 2x2 matrix char S and finds the length of the strings that exists in each row.a string in C language end with the byte 0.the result is stored in table R. use registers where you can.thnx for help

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Actually you don't have a c program... not yet anyway... There are at least 2 syntax errors that will stop it from compiling.

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    4
    actually i don't want to compile it...this exercise was in an exam exactly as i gave it ...i only have to write the assembly code

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by mariakat View Post
    actually i don't want to compile it...this exercise was in an exam exactly as i gave it ...i only have to write the assembly code
    I guess the point is, you can have the compiler do it for you.

  5. #5
    Registered User
    Join Date
    Feb 2011
    Posts
    4
    you are right but i don't have a compiler to do this.thnx anyway

  6. #6
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,457
    Can you give it a try? Surely you have some class notes or books to reference. I'll give you a hint. You need nested loops. Google turned up some decent examples of loops in assembly. Translating from whatever assembly to MIPS shouldn't be too difficult. Also, this is probably not the best place, since this is a C forum. I'm not, and suspect few on this board are, experts in MIPS assembly.

  7. #7
    Registered User
    Join Date
    Feb 2011
    Posts
    4
    thnx for the advice but as i said i'm not good at all in assembly.thnx anyway for the hint,i'll give it a shot

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by mariakat View Post
    you are right but i don't have a compiler to do this.thnx anyway
    You have access to the internet. You can have a free compiler in 10 minutes or less...

  9. #9
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    If you are using MSVS it has a feature to change platform targets and I believe one of the many available is MIPS.

    Select the project from the solution explorer and right click. From there it is Properties->Configuration Properties->Linker->Advanced->Target machine

    MIPS is in the list of supported targets.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help me convert c to mips
    By chicken in forum C Programming
    Replies: 3
    Last Post: 11-03-2010, 10:35 AM
  2. Converting C into MIPS Assembly
    By clag in forum C Programming
    Replies: 5
    Last Post: 02-13-2010, 06:48 PM
  3. A question of the MIPS assembly program
    By ok_good in forum Tech Board
    Replies: 0
    Last Post: 05-03-2006, 10:13 PM
  4. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 03:28 AM
  5. C,C++,Perl,Java
    By brusli in forum C Programming
    Replies: 9
    Last Post: 12-31-2001, 02:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21