Leo --

Here is a simple Jako test program, which exercises the assignment syntax:

var int a, b, c;
var num d, e;
var str f, g;

a = 5;
a = b = c = 5;

d = 3.14;
d = e = 3.14;

f = "Howdy";
f = g = "Howdy";

a = b;
a = b = c;

Here it is compiled to IMC:

                 .sub     __MODULE__ 
                 .local   int a                     # var int a;
                 .local   int b                     # var int b;
                 .local   int c                     # var int c;
                 .local   float d                   # var num d;
                 .local   float e                   # var num e;
                 .local   string f                  # var str f;
                 .local   string g                  # var str g;
                 a =      5                         # a = 5;
                 a =      5                         # a = 5;
                 b =      5                         # b = 5;
                 c =      5                         # c = 5;
                 d =      3.14                      # d = 3.14;
                 d =      3.14                      # d = 3.14;
                 e =      3.14                      # e = 3.14;
                 f =      "Howdy"                   # f = "Howdy";
                 f =      "Howdy"                   # f = "Howdy";
                 g =      "Howdy"                   # g = "Howdy";
                 a =      b                         # a = b;
                 a =      c                         # a = c;
                 b =      c                         # b = c;
                 end 
                 .end 

And, here is the PASM imcc turns it into:

__MODULE__:
                 set I2, 5
                 set I2, 5
                 set I0, 5
                 set I1, 5
                 set N0, 3.14
                 set N0, 3.14
                 set N0, 3.14
                 set S0, "Howdy"
                 set S0, "Howdy"
                 set S0, "Howdy"
                 set I2, I0
                 set I2, I1
                 set I0, I1
                 end 

I don't understand how d and e both become N0, nor how both f and g become
S0. a, b, and c all seem to get their own registers. Is there some
optimization going on here since in both cases (num and str), the assigns
are from the same constant table location? Is imcc smart enough to realize
that the above transformation doesn't change the semantics of my program,
or is it perhaps a bug?


Regards,

-- Gregor

Reply via email to