<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Tony..are you sure..I'm not sure what I said is true.<BR>
It seems clear that the host integer size is well abstracted while interpreting target numbers.<BR>
<BR>
I am more certain that [-1 .. 1] is empty, and this is likely a problem in TInt.Subtract..<BR> <BR>
PROCEDURE Add (READONLY a, b: Int; VAR r: Int): BOOLEAN =<BR> (* It is safe for r to alias a or b *)<BR> VAR n := MIN (a.n, b.n); carry := 0; r_sign := Sign.Bad;<BR> a_sign := CheckSign (a, n); b_sign := CheckSign (b, n);<BR> BEGIN<BR> IF a_sign = Sign.Bad THEN RETURN FALSE END;<BR> IF b_sign = Sign.Bad THEN RETURN FALSE END;<BR> r.n := n;<BR> FOR i := 0 TO n-1 DO<BR> carry := a.x[i] + b.x[i] + carry;<BR> r.x[i] := And (carry, Mask);<BR> carry := RShift (carry, BITSIZE (IByte));<BR> END;<BR> r_sign := CheckSign (r, n); <*ASSERT r_sign # Sign.Bad*><BR> RETURN (a_sign # b_sign) OR (a_sign = r_sign);<BR> END Add;<BR>
<BR>
PROCEDURE Subtract (READONLY a, b: Int; VAR r: Int): BOOLEAN =<BR> (* It is safe for r to alias a or b *)<BR> VAR n := MIN (a.n, b.n); borrow := 0; r_sign := Sign.Bad;<BR> a_sign := CheckSign (a, n); b_sign := CheckSign (b, n);<BR> BEGIN<BR> IF a_sign = Sign.Bad THEN RETURN FALSE END;<BR> IF b_sign = Sign.Bad THEN RETURN FALSE END;<BR> r.n := n;<BR> FOR i := 0 TO n-1 DO<BR> borrow := a.x[i] - b.x[i] - borrow;<BR> r.x[i] := And (borrow, Mask);<BR> borrow := And (RShift (borrow, BITSIZE (IByte)), 1);<BR> END;<BR> r_sign := CheckSign (r, n); <*ASSERT r_sign # Sign.Bad*><BR> RETURN (a_sign = b_sign) OR (a_sign = r_sign);<BR> END Subtract;<BR><BR>
Is it not adequate to treat carry and borrow as one it, zero or non-zero?<BR>
Thinking in decimal about addition -- 9 + 9 = 18.<BR>
You can never overflow to 20, 30, 40, etc.<BR>
<BR>
For substraction 0 - 9 = -9, never -10 or lower.<BR>
<BR>
However "1" is a full decimal digit, not a bit.<BR>
In this case, the digits are bytes.<BR>
<BR>
Aha, so maybe the problem is the "and"?<BR>
<BR>
Let's check pm3 and decm3 3.6 again..<BR>
No, pm3 has the and too.. hm. I have to refresh some of my bit twiddling algorithms..<BR>
<BR>
- Jay<BR><BR>
<BLOCKQUOTE>
<HR id=EC_stopSpelling>
CC: m3devel@elegosoft.com<BR>From: hosking@cs.purdue.edu<BR>To: jayk123@hotmail.com<BR>Subject: Re: [M3devel] tangential 64 bit...<BR>Date: Tue, 26 Feb 2008 15:14:18 -0500<BR><BR>
<DIV><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate">
<DIV style="WORD-WRAP: break-word"><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate">
<DIV>Indeed, on a 32-bit platform [16_0 .. 16_ffffffff] is an empty type, because 16_ffffffff is interpreted as an INTEGER constant with value -1, so the subrange is [0..-1].</DIV>
<DIV><BR class=EC_webkit-block-placeholder></DIV>
<DIV>This implies that one should not be using a 32-bit compiler to compile the 64-bit version of BasicCtypes.i3 in the first place.</DIV>
<DIV><BR></DIV>
<DIV>Of course, this also implies that one cannot directly cross-compile to 64-bit targets from 32-bit hosts, which is kind of broken. I suppose we could use LONGINT as necessary, realizing that LONGINT and INTEGER are distinct types that happen to have the same representation on 64-bit machines but different representation on 32-bit machines. Does anyone know if it was *ever* possible in the old PM3 to cross-compile from 32-bit to 64-bit? Presumably one needs an intermediate step where the C types used on the cross-compile host match those of the host instead of the target.</DIV>
<DIV><BR class=EC_webkit-block-placeholder></DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></DIV></SPAN></DIV>
<DIV>
<DIV>On Feb 26, 2008, at 1:53 PM, Jay wrote:</DIV><BR class=EC_Apple-interchange-newline>
<BLOCKQUOTE><SPAN class=EC_Apple-style-span style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate">
<DIV class=EC_hmmessage style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">alpha/osf doesn't work because basictypes/ctypes has a problem with the 32bit or 64bit types.<BR>specifically "unsigned long" is "empty" for some reason and many errors cascade from that.<BR> <BR>if you change:<BR> unsigned_int = [16_0 .. 16_ffffffff];<BR>to<BR> unsigned_int = [16_0 .. 16_fffffffe];<BR> <BR>you get:<BR> <BR> <BR>***<BR>*** runtime error:<BR>*** An array subscript was out of range.<BR>*** file "../src/TWord.m3", line 199<BR>***<BR><BR>Presumably fixing this first problem is the first step in any "real" 64 bit target (SPARC64, PPC64, AMD64, IA64), and the second problem should just be fixed as a matter of course.<BR> <BR>I know this is the least of anyone's concerns..<BR> <BR> - Jay<BR><BR><BR>
<HR>
Connect and share in new ways with Windows Live.<SPAN class=EC_Apple-converted-space> </SPAN><A href="http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008" target=_blank>Get it now!</A></DIV></SPAN></BLOCKQUOTE></DIV><BR></BLOCKQUOTE><br /><hr />Climb to the top of the charts! Play the word scramble challenge with star power. <a href='http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan' target='_new'>Play now!</a></body>
</html>