Gettickcount and in-line ASM code

Hi. Suppose that we have an in-line ASM code in a Delphi procedure. In this code, we consume all off the free registers like eax,ebx and etc. Now, how can we measure the time requiring for executing this code using Gettickcount function? For example, consider the following code:

[code]
procedure Test();
var i:integer;
begin
i:=gettickcount;

asm
...
//some assembly code here
...

end;

showmessage(inttostr(gettickcount-i));

end;


[/code]
If we run this code, a exception raises. But what is the problem? Any other solution appreciated.Thanks

Comments

  • : Hi. Suppose that we have an in-line ASM code in a Delphi procedure. In this code, we consume all off the free registers like eax,ebx and etc. Now, how can we measure the time requiring for executing this code using Gettickcount function? For example, consider the following code:
    :
    : [code]
    : procedure Test();
    : var i:integer;
    : begin
    : i:=gettickcount;
    :
    : asm
    : ...
    : //some assembly code here
    : ...
    :
    : end;
    :
    : showmessage(inttostr(gettickcount-i));
    :
    : end;
    :
    :
    : [/code]
    : If we run this code, a exception raises. But what is the problem? Any other solution appreciated.Thanks
    :

    Hi!

    I'v tried the above code, all works fine. Maybe something goes wrong with the inline assembly part, which is not shown in your example. For example you do not restore eax value.

    I'v tried the next silly embedded loop sample:

    [code]
    procedure Test();
    var i:integer;
    begin
    i:=gettickcount;

    asm
    push eax
    mov ecx,255
    @back1:
    push ecx
    mov ecx,65535
    @back:
    push ebx
    pop ebx
    loop @back
    pop ecx
    loop @back1
    pop eax
    //some assembly code here


    end;

    showmessage(inttostr(gettickcount-i));

    end;
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion