Step
6 - Loop management code
The desired algorithm is completed, but
the loop management code is still missing: the assumption that the ECX
register contains the number of iterations required to fully compute the
difference image is made. The first step is declaring the loop entry point:
since this simple project has no startup code, the first instruction of
the loop is also the first of the source list, so you should select it
then choose Edit|Mark Entry Point from the menu.

This simple window associates a name to
an entry point: this name will be required when adding jump instructions,
so choosing a meaningful one will make the code more readable.
The instruction associated to an entry
point is now displayed with a red arrow on the left. To remove an entry
point, you should just select the instruction and choose Edit|Remove Entry
Point from the menu.
The final step is adding the loop epilogue:
the missing instructions update the pointers to the images, adjust the
loop counter and eventually exit the loop. These are all scalar instructions,
so you can find them by clicking the right mouse button, grouped at the
end of the list. Clicking on Scalar instructions|Adjust pointer, the following
window pops up:

You can choose the x86 register to update
from the drop-down list, and type the desired offset in the text field
on top: you can enter both positive and negative numbers, since it is up
to Quexal to choose the x86 instruction that optimally adjusts the pointer.
After updating the EAX, EDX and EBX pointers, the value of the loop counter
is decreased by adding –1 to the register ECX. The final instruction is
the conditional jump to the top of the loop: clicking on Scalar instructions|Jump
opens the Jump window.

You can choose the entry and the condition:
in this case the loop must be iterated until the ECX register reaches zero.
Clicking the OK button will close the Jump window, and step back to the
main window that shows now the final source code.

By now the benefits of having an interactive
development environment that guides the developer step by step should be
evident: you have been building the source code by point-and-click, choosing
among options specific to each instruction in a visual way. You can forget
both the mnemonics of MMX/SSE
instructions, given that the source list uses a simple english-like language,
and MMX registers, since you can work on variables. These improvements
really flatten the learning curve, and the traditional way of writing MMX/SSE
code should appear unpleasant at least.
|