I have a fragment of code that looks like this:

VAR     z, a, alpha, b, c, d, e: Int64;
        f: DOUBLE;

BEGIN
  td:= td + 0.5;                       // astronomical to civil
  z:= Floor(td);
  f:= td - z;
  IF z < 2299161.0 THEN
    a:= z
  ELSE BEGIN
    alpha:= Floor((z - 1867216.25) / 36524.25);
    a:= z + 1 + alpha - Floor(alpha / 4)
  END;

Using 2.4.4 with -a -al -s this compiles to a .s which looks like this:

.Ll34:
# [439] IF z < 2299161.0 THEN
        ld      [%i6-32],%o0
        ld      [%i6-28],%o1
        call    fpc_int64_to_double
        nop
        sethi   %hi(_$MOONPHASE$_Ld8),%o0
        ld      [%lo(_$MOONPHASE$_Ld8)+%o0],%f1
        fcmpd   %f0,%f1
        nop
        fbl     .Lj87
        nop
        ba      .Lj88
        nop
.Lj87:
        .stabn 68,0,441,.Ll35 - MOONPHASE_JYEAR$DOUBLE$INT64$INT64$DOUBLE
.Ll35:
# [441] a:= z

This appears to be the only place in the program where fcmpd %f0,%f1 is generated, although the same opcode is generated with other registers as opeands. Assembling with as (2.17 or 2.18), I get this error:

moonphase.s:629: Error: Illegal operands

If I change the code to look like this:

  f:= td - z;
  IF z - 2299161.0 < 0 THEN
    a:= z
  ELSE BEGIN

it generates this:

.Ll34:
# [440] IF z - 2299161.0 < 0 THEN
        ld      [%i6-32],%o0
        ld      [%i6-28],%o1
        call    fpc_int64_to_double
        nop
        sethi   %hi(_$MOONPHASE$_Ld8),%o0
        ld      [%lo(_$MOONPHASE$_Ld8)+%o0],%f1
        fsubs   %f0,%f1,%f0
        sethi   %hi(_$MOONPHASE$_Ld9),%o0
        ld      [%lo(_$MOONPHASE$_Ld9)+%o0],%f1
        fcmps   %f0,%f1
        nop
        fbl     .Lj87

Having a workaround makes this not particularly crucial, but I'd welcome any comments.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to