The Clobber Parameter (GNAT User’s Guide for Native Platforms)

#### 10.6.1 The `Clobber` Parameter ¶

One of the dangers of intermixing assembly language and a compiled language such as Ada is that the compiler needs to be aware of which registers are being used by the assembly code. In some cases, such as the earlier examples, the constraint string is sufficient to indicate register usage (e.g., `"a"` for the `eax` register). But, more generally, the compiler needs an explicit identification of the registers that are used by the Inline Assembly statements.

Using a register that the compiler doesn’t know about could be a side effect of an instruction (like `mull`, which stores its result into both `eax` and `edx`). It can also arise from explicit register usage within your assembly code; for example:

>     Asm ("movl %0, %%ebx" & LF & HT &
>          "movl %%ebx, %1",
>          Outputs => Unsigned_32'Asm_Output ("=g", Var_Out),
>          Inputs  => Unsigned_32'Asm_Input  ("g", Var_In));

where the compiler (since it does not analyze the `Asm` template string) does not know you are using the `ebx` register.

In such cases you need to supply the `Clobber` parameter to `Asm`, to identify the registers used by your assembly code:

>     Asm ("movl %0, %%ebx" & LF & HT &
>          "movl %%ebx, %1",
>          Outputs => Unsigned_32'Asm_Output ("=g", Var_Out),
>          Inputs  => Unsigned_32'Asm_Input  ("g", Var_In),
>          Clobber => "ebx");

The Clobber parameter is a static string expression specifying the register(s) you are using. Note that register names are ‘not’ prefixed by a percent sign. Also, if more than one register is used, you separate their names by commas; e.g., `"eax, ebx"`

The `Clobber` parameter has several additional uses:

- Use ‘register’ name `cc` to indicate that flags might have changed
- Use ‘register’ name `memory` if you changed a memory location