translating the c if then statement

translating the c if then statement

    example one ;

    R1 = *X;
    if (R1<0)
        R1 = -R1;
    R3 = R1 + R1;


        LD      R1, (X)
        BNN     R1, L
        MUL     R1,R1, #-1
    L   ADD     R3,R1,R1


    example two;

    R1 = 0;
    for(R2=1, R2<=5; R2++)
        R1 = R1 + R2;
    R3 = R1 + R1;

        LD  R1, #0
        LD  R2, #1
    FOR BGT R2, #5, L     // if R2>5 stop
        ADD R1, R1, R2  //R1 = R1 + R2
        ADD R2, R2, #1    //R2++
        JMP FOR
    L   ADD R3, R1, R1