Thread: Convert ASM to C Code

  1. #1
    Registered User
    Join Date
    Oct 2009

    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?

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

    Assembly Forum

  3. #3
    Registered User
    Join Date
    Jan 2010
    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:
    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, 01:16 AM
  2. Machine code, asm, poop
    By tim545666 in forum A Brief History of
    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