While I was disassembling my own C code for practice I saw an interesting point which I want to share with you guys and needs to know the answer as I always get from here. Now, the interesting point is when I'm disassembling for switch cases when I'm making cases for one-digit numbers like 1, 2, etc. the disassembler is using jump-table for them but when I'm making cases for digits with zeroes like 10, 200, 300, etc. I'm seeing the disassembly with no jump-table but only a bunch of CMPs and JCCs one after another. I can't figure out why it's doing this but it's very interesting, can anyone tell me why? My two codes...
int number=5;
switch (number) {
case 1:
case 2:
case 3:
printf("One, Two, or Three.\n");
break;
case 4:
case 5:
case 6:
printf("Four, Five, or Six.\n");
break;
default:
printf("Greater than Six.\n");}}
and disassembly for it...
now the code but with cases with numbers like 200, etc.
int number=500;
switch (number) {
case 100:
case 200:
case 300:
printf("100, 200, or 300.\n");
break;
case 400:
case 500:
case 600:
printf("400, 500, or 600.\n");
break;
default:
printf("Greater than Six.\n");}}
and disassembly for it...
it seems so chatty. Thanks in advance!