[M3commit] [M3devel] m3back using Target.Int in place of INTEGER a lot now

Tony Hosking hosking at cs.purdue.edu
Thu Jan 21 09:40:36 CET 2010


You should not assume that aliasing works for any of these operations.

Antony Hosking | Associate Professor | Computer Science | Purdue University
305 N. University Street | West Lafayette | IN 47907 | USA
Office +1 765 494 6001 | Mobile +1 765 427 5484




On 21 Jan 2010, at 02:02, Jay K wrote:

> Hm. Ok. TInt.Multiply allows aliasing but TWord.Multiply does not.
>  
>  
> MODULE Main;
> IMPORT RTIO, Target, TInt, TWord;
> VAR a,b:Target.Int;
> BEGIN
> EVAL TInt.FromInt(1, BYTESIZE(INTEGER), a);
> EVAL TInt.FromInt(1, BYTESIZE(INTEGER), b);
> TWord.Multiply(a, b, a);
> RTIO.PutText(TInt.ToText(a));
> RTIO.Flush();
> END Main.
> 
>  
> prints 0.
>  
> The code in m3back:
>  
>  
> PROCEDURE doindex_address (t: T; shift, size: INTEGER; neg: BOOLEAN) =
> ...
>         (* Beware TWord.Multiply: x * 1 = 0 *)
>         IF NOT TInt.Multiply(stop0.imm, tsize, stop0.imm) THEN
>           t.Err("doindex_address: multiply overflowed");
>         END;
> 
>  
>  
>  - Jay
> 
>  
> From: hosking at cs.purdue.edu
> Date: Wed, 20 Jan 2010 20:00:39 -0500
> To: hosking at cs.purdue.edu
> CC: m3devel at elegosoft.com; m3commit at elegosoft.com; jay.krell at cornell.edu
> Subject: Re: [M3devel] [M3commit] m3back using Target.Int in place of INTEGER a lot now
> 
> Jay, I don't know what you are talking about there being a bug in TWord.Multiply.
> 
> This little program prints out 2, as would be expected:
> 
> MODULE Main;
> IMPORT RTIO, TInt, TWord, Target;
> 
> VAR i := TInt.Two;
>     j: Target.Int;
>     buf: ARRAY[0..10] OF CHAR;
> BEGIN
>   TWord.Multiply (i, TInt.One, j);
>   FOR k := 0 TO TInt.ToChars (i, buf) DO
>     RTIO.PutChar(buf[k]);
>   END;
>   RTIO.PutChar('\n');
>   RTIO.Flush();
> END Main.
> 
> 
> On 20 Jan 2010, at 18:59, Tony Hosking wrote:
> 
> Where's the bug in TWord.Multiply?
> If there were a bug we would have seen it by now surely?
> 
> Antony Hosking | Associate Professor | Computer Science | Purdue University
> 305 N. University Street | West Lafayette | IN 47907 | USA
> Office  +1 765 494 6001  +1 765 494 6001 | Mobile  +1 765 427 5484  +1 765 427 5484
> 
> 
> 
> 
> On 20 Jan 2010, at 10:05, Jay K wrote:
> 
> This is fairly large and tedious. If anyone has the patience to look at every single line, please do. Thanks.
> I did look through pretty much every single line in search of the one bug I saw working on it.
> It turns out the bug was in TWord though. TWord.Multiply(x, 1) = 0.
> Which broke INC, it was adding 0 instead 1.
> You could see the bug in RTIO.PutString where it just kept outputing the first character.
> So I use TInt.Multiply instead.
>  
>  - Jay
>  
> From: jay.krell at cornell.edu
> To: jkrell at elego.de; m3commit at elegosoft.com
> Date: Wed, 20 Jan 2010 15:02:27 +0000
> Subject: Re: [M3commit] CVS Update: cm3
> 
> diff attached
> 
> 
> 
> 
> 
>  
> > Date: Wed, 20 Jan 2010 16:01:32 +0000
> > To: m3commit at elegosoft.com
> > From: jkrell at elego.de
> > Subject: [M3commit] CVS Update: cm3
> > 
> > CVSROOT: /usr/cvs
> > Changes by: jkrell at birch. 10/01/20 16:01:32
> > 
> > Modified files:
> > cm3/m3-sys/m3back/src/: Codex86.i3 Codex86.m3 M3x86.m3 
> > M3x86Rep.i3 Stackx86.i3 Stackx86.m3 
> > cm3/m3-sys/m3middle/src/: TInt.i3 TInt.m3 
> > 
> > Log message:
> > convert much of m3back to use Target.Int instead of INTEGER
> > This should at least allow it to propagate constant LONGINTs
> > as well as perhaps otherwise help with implementing LONGINT,
> > since the virtual stack is now of Target.Int instead of INTEGER
> > 
> > Beware that TWord.Multiply(x, 1) = 0, so I use TInt.Multiply instead
> > 
> > Also note that there's still a lot of "INTEGER" used.
> > 
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3commit/attachments/20100121/90bb8142/attachment-0002.html>


More information about the M3commit mailing list