The presence of an __asm block in a function affects optimization in a few different ways. First, as you might expect, QuickC doesn't try to optimize the __asm block itself. What you write in assembly language is exactly what you get.
Second, the presence of an __asm block affects register variable storage. (For a discussion of register variables, see topic .) Under normal circumstances, QuickC automatically stores variables in registers. This is not done, however, in any function that contains an __asm block. To get register variable storage in such a function, you must request it with the register keyword.
Since the compiler stores register variables in the SI and DI registers, these registers represent variables in functions that request register storage. The first eligible variable is stored in SI and the second in DI. Preserve SI and DI in such functions unless you want to change the register variables.
Keep in mind that the name of a variable declared with register translates directly into a register reference (assuming a register is available for such use). For instance, if you declare
register int sample;
and the variable sample happens to be stored in SI, then the __asm instruction
__asm mov ax, sample
is equivalent to
__asm mov ax, si
If you declare a variable with register and the compiler cannot store the variable in a register, QuickC issues a compiler error if you reference the variable in an __asm block. The solution is to remove the register declaration from that variable.
Register variables form a slight exception to the general rule that an assembly-language statement can contain no more than one C symbol. If one of the symbols is a register variable, for example,
register int v1;
int v2;
then an instruction can use two C symbols, as in
mov v1, v2
Finally, the presence of inline assembly code inhibits loop optimization for the entire function in which the code appears. (Loop optimization can be selected with the /Ol compiler option; see online help.) This optimization is suppressed no matter which compiler options you use.