I'm stuck on a problem where I have to provide x86 code for a switch statement given in C. My instructor gives an example in one of his lectures, but I am having difficulty understanding this example. We use Red Hat Linux for this course.
In the first section (which is red)
The code checks if a is less than 1, and jumps to the default if it is which makes sense.
In the second section (which is green)
The code checks if a is greater than 4, and jumps to the default if it is which makes sense.
In the third section (which is red)
.T gets put into register %rbx
1 is subtracted from the register, %eax, which has a (why?)
8 is put into %ecx
the product 8 * (a - 1) is stored into %eax (why?)
The instruction "movslq" is used, but I do not know what it does. I've used movl and the conditional move instructions, but I'm not quite sure what movslq is and am having a hard time finding this out with google.
And everything after that point is uncertain to me because I do not understand why some things are being done, for the most part, or what movslq does.