I am working on an Ingenico's EDC terminal. The below code was existing from previous implementation. While debugging I came across this block of code which I am facing difficulty in understanding.
short bankPEM = 0;
//bankPEM = 41; //Chip
bankPEM = 17; //Swipe
//bankPEM = 801; //Fallback
switch(bankPEM)
{
case 021: cout<<"021"; break; //Swipe
case 051: cout<<"051"; break; //Chip
case 801: cout<<"801"; break; //Fallback
default: cout<<"Default"; break;
}
bankPEM
is a short variable. I found below exection observation:
- When it contains
41
,case 051
is executed. - When it contains
17
,case 021
is executed. - When it contains
801
,case 801
is executed.
I expected the code to executed default
case for number 1 & 2.
Can anyone show some light in this case.
I am also converting the code to assembly language. I will share my understanding after debugging the assembly code.
Thanks in advance.