Delphi XE byte array index
<p>I use simple circular buffer like this</p>

<pre><code>var
  Values: array [byte] of single;
  ptr: byte;
</code></pre>

<p>In this test example</p>

<pre><code>for ptr:=0 to 10 do Values[Byte(ptr-5)]:=1;
</code></pre>

<p>I expect to have set to 1 first 5 values and last 5 values, but XE4 compiller produce incorrect code, its using 32bit pointer math to calculate array index:</p>

<pre><code>for ptr:=0 to 10 do Values[Byte(ptr-5)]:=1;
005B94BB C645FB00         mov byte ptr [ebp-$05],$00
005B94BF 33C0             xor eax,eax
005B94C1 8A45FB           mov al,[ebp-$05]
005B94C4 C78485E0FBFFFF0000803F mov [ebp+eax*4-$0420],$3f800000
005B94CF FE45FB           inc byte ptr [ebp-$05]
005B94D2 807DFB0B         cmp byte ptr [ebp-$05],$0b
005B94D6 75E7             jnz $005b94bf
</code></pre>

<p>Is it my wrong code and whats proper way to operate byte indexes?</p>