سؤال

Why when it goes to the cycle in ECX there some big random value insted of 0? And is there other way to make cycle here?

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

function FPUTest(a:Double):Double;
asm
  FINIT
  FLD a
  MOV ecx,0
  @cycle:
    FADD st(0), st(0)
  loop @cycle
end;

var a:Integer;
begin
  readln(a);
  Writeln(FPUTest(a));
end

.

هل كانت مفيدة؟

المحلول

ECX is a countdown register with respect to the loop instruction. Starting with zero means it will loop through its full 32-bit range, beginning with 0xffff ffff. Sometimes that is useful.

In this case, if you want to loop 5 times, begin with ecx set to 5.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top