:icon_confused:
I've wished someone gave me a feedback after testing it
JWasm32 told me that MSVCR110.dll was missing (on Win7-32). After fixing this, here are some timings:
AMD Athlon(tm) Dual Core Processor 4450B (SSE3)
22317 cycles for 100 * C style for loop
31539 cycles for 100 * Basic style for loop
14 bytes for C style for loop
30 bytes for Basic style for loopSo your code is really competitive :t
Here are the two loops compared:
m2m eax, 40
.for (ecx = 0¦ecx<=eax¦ecx+=1)
inc edx
; inc eax hangs .endfor
m2m eax, 41
For_ ecx=0 To eax-1
inc eax
; inc eax OK NextThe Basic loop is a bit more flexible, as it can handle
eax+whatever, and references to the
initial eax (or whatever) while looping. On the other hand, the C loop is shorter and faster. In real life, if speed was an issue, I would use a .Repeat ... .Until construct anyway, but I guess for C coders your add-on to JWasm is really handy :t
P.S.: I made a little test with Pelles C:
int n=100;
__asm int 3;
__asm nop;
for (jjc=0; jjc<n; jjc++) {
n++;
}
__asm nop;
00401DD5 |. 90 nop
00401DD6 |. 31C0 xor eax, eax
00401DD8 |. BA 64000000 mov edx, 64
00401DDD |> 42 /inc edx
00401DDE |. 40 |inc eax
00401DDF |. 39D0 |cmp eax, edx
00401DE1 |.^ 7C FA \jl short 00401DDD
00401DE3 |. 90 nopHeavily optimised (bravo, Pelle :t), and it seems indeed that C keeps referring to the
current loop counter, i.e. this loop stops only for edx = 80000000h 8)