Convert ASM to C Code

This is a discussion on Convert ASM to C Code within the C Programming forums, part of the General Programming Boards category; Basically I want to convert this into C. addi $s3, $0, 1 add $t0, $s2, $s3 lw $t1, 0($t0) add ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    32

    Convert ASM to C Code

    Basically I want to convert this into C.

    addi $s3, $0, 1
    add $t0, $s2, $s3
    lw $t1, 0($t0)
    add $t2, $s1, $t1
    lw $s4, 0($t2)

    ($s0 = A, $s1 = B, $s2 = C and so on..)
    This could be trivial but what I did was

    int C = 1;

    but for the second line since t0 are temp variables I decided to use an array.
    so I do

    int A[i] = C + D;

    is this correct?

    next would be

    int B[0] = 0;

    am I on the right track?
    Thanks!

  2. #2
    Noob AnishaKaul's Avatar
    Join Date
    Jan 2010
    Location
    Gurgaon, India
    Posts
    115
    Did you try posting here ?

    Assembly Forum

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    My ppc assembler knowledge isn't all that good but I think the result is
    D = 1;
    E = (*(B + *(C+1)) & 0xFFFF0000) & 0xFFFF0000;
    Pseudo-code to verify I didn't mess up somewhere:
    Code:
    D = 1
    temp0 = C+D
    temp1 = *(temp0) & 0xFFFF0000
    temp2 = B + temp1
    E = *(temp2) & 0xFFFF0000
    although I guess the bit mask could also be 0x0000FFFF depending on endianness, I'm not sure what the ppc uses.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc asm code syntax
    By Uberapa in forum C Programming
    Replies: 4
    Last Post: 06-15-2007, 02:16 AM
  2. Machine code, asm, poop
    By tim545666 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 04-02-2002, 01:27 AM
  3. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM
  4. Replies: 4
    Last Post: 01-16-2002, 12:04 AM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM

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