The code that follows shows an example of branching on an en

The code that follows shows an example of branching on an enumerated type value in a switch statement. Recall that enumerated types in C are simply a way to introduce a set of names having associated integer values. By default, the values assigned to the names go from zero upward. In our code, the actions associated with the different case labels have been omitted. The part of the generated assembly code implementing the different actions is shown in Figure The annotations indicate the argument locations, the register values, and the case labels for the different jump destinations. Fill in the missing parts of the C code. It contained one case that fell through to another - try to reconstruct this. The part of the generated assembly code implementing the different actions is shown in Figure. The annotations indicate the argument locations, the register values, and the case labels for the different jump destinations. Fill in the missing parts of the C code. It contained one case that fell through to another - try to reconstruct this.

Solution

Switch statment is like if else block. After each case statement, break needs to be given otherwise results in fallthrough conditon.

long result=0;

Switch(action)

{

MODE_A : swapping is occuring between two varibles; break;

MODE_B: similar kind of swapping as MODE_A is occuring between two varibles; break;

MODE_C: result = *p1 ; *p2=59; break;

MODE_D : fallthrough to E (*p1=*p2) ;break;

MODE_E : result = 27; break;

DEFAULT: result = 12

}

return result;

(in assembly language ret means break)

 The code that follows shows an example of branching on an enumerated type value in a switch statement. Recall that enumerated types in C are simply a way to in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site