...
Thank you again!
With your sample, I was able to do what I wanted. As I remember, the assembler much faster than any high-level language.
Algorithm sleftest (hash compared!) with 300MB data:
pascal implementation: 35,32 MB/s
assembler implementation: 333,88 MB/s
It's about 10 times faster...
But I have a question, to tell the truth, I don't know exactly why don't work your first sample (you wrote you forget dereference pointers), so in my algorithm I use constant array values. My question is, I can access these array constant safely (ADD_ARRAY_SAMPLE) with my code?
Sample (isn't the real algorithm), x86 version:
procedure TForm1.Operation2(const Stream: TMemoryStream);
const
ADD_ARRAY_SAMPLE: array[0..2] of byte = ($01, $02, $03);
var
LSize, Counter: SizeInt;
ADD_ARRAY_SAMPLE_PTR: pointer;
begin
LSize := Stream.Size;
ADD_ARRAY_SAMPLE_PTR:= @ADD_ARRAY_SAMPLE;
Counter:=0;
{$ASMMODE INTEL}
asm
mov esi, Stream
mov ecx, Counter // ADD_ARRAY_SAMPLE index
mov ebx, 0 //Stream index
@@StartLoop:
mov edx, [esi].TMemoryStream.FMemory
mov al, [edx+ebx]
mov edx, ADD_ARRAY_SAMPLE_PTR
mov ah, [edx+ecx]
add al, ah
mov edx, [esi].TMemoryStream.FMemory
mov BYTE PTR [edx+ebx], al
cmp ecx, 2
je @@ARRAY_MAX
inc ecx
jmp @@Next
@@ARRAY_MAX:
mov ecx, 0
@@Next:
inc ebx
cmp ebx, LSize
je @@EndLoop
jmp @@StartLoop
@@EndLoop:
end ['esi', 'eax', 'ebx', 'ecx', 'edx'];
Stream.Position := 0;
end;
... and I have a simple question ctrl-d (jedi code format) why doesn't work if asm code available in the source?
Thank you!