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 counter=0;
if (counter > 10){ //condition checking grater than allow to loop
counter =0;}
else { //less than 10 counter += 1
counter = counter +1;}
return (0);
}
Result:
Assembly language code:
TTL transfer
AREA Myprog, CODE, READONLY
ENTRY
EXPORT main
main
MOVS R1,#9 ;Initilize the value with 9
CMP R1, #10 ; compare to 10
BLE incr_counter ; if less or equal, then branch
MOVS R1, #0 ; counter = 0
B counter_done ; branch to counter_done
incr_counter
ADDS R1, R1, #1 ; counter = counter +1
counter_done
SWI &11
END
Result: