Practice Questions for Simple Control Flow:

 

Implement the following C pseudo-code in 68k assembly

 

A)

Unsigned int i;

Unsigned int j;

Unsigned int k;

 

if (i == j)

{

   if ( j > 10 )

     k = 20;

   else

     if  (j == 10)

     k = 10;

   else

     k = i;

}

else if ( i == k)

     j = k;

 

Notice that the numbers are unsigned and not signed. Hence avoid the signed conditions (e.g., GT).

 

B) Repeat A) but with signed integers

 

C)

 

if (i < j) i = j + 10;

if (i < k) i = i + k + 20;

k = j + i;