Adsense

Write embedded C and assembly code to understand program flow instructions for "for loop".

Usually, we start coding with assembly and than we move to the embedded C code. In this case we first understand the  embedded C code and than we will write the equivalent assembly code to mimic the same thing.

Embedded C code:

int main ()
{
volatile unsigned int total, i;

total = 0;                    // initialize the total
        for (i=0;i<5;i=i+1)
        {
        total = total + i;
        }
return(0);
    
}

       
 Result:

 

Assembly language code:

        TTL transfer
        AREA Myprog, CODE, READONLY
ENTRY
        EXPORT main
main
        MOVS R2, #0 ; Total = 0
        MOVS R1, #0 ; i = 0
loop
        ADDS R2, R2, R1 ; Total = Total + i
        ADDS R1, R1, #1 ; i = i + 1
        CMP R1, #5 ; compare i to 5
        BLT loop ; if less than then branch to loop
done
        SWI &11
        END

Result:


Write a ARM cortex M0+ assembly language code based on arithmatc and logical instructions.

 Problem 1: Implement following code conversions to convert binary no 0x89ABCDEF(32-bits) into a) BCD (64-bits)   b) Gray (32-bits) Problem...