Browse Source

Fix an embarrasing error in m68k which fixes 60 tests.

m68k/cgcpu.pas, tcg68k.g_flags2reg:
  * don't sign extend the flag value which was stored to the register, but instead do a "AND 1" on it to reduce it to 1 bit; afterall Booleans in Pascal are either 0 or 1 and not 0 or $FF

+ added test

git-svn-id: trunk@25598 -
svenbarth 12 years ago
parent
commit
2c93687c5a
3 changed files with 15 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/m68k/cgcpu.pas
  3. 11 0
      tests/tbs/tb0601.pp

+ 1 - 0
.gitattributes

@@ -10018,6 +10018,7 @@ tests/tbs/tb0597.pp svneol=native#text/plain
 tests/tbs/tb0598.pp svneol=native#text/plain
 tests/tbs/tb0598.pp svneol=native#text/plain
 tests/tbs/tb0599.pp svneol=native#text/plain
 tests/tbs/tb0599.pp svneol=native#text/plain
 tests/tbs/tb0600.pp svneol=native#text/plain
 tests/tbs/tb0600.pp svneol=native#text/plain
+tests/tbs/tb0601.pp svneol=native#text/pascal
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tbs0594.pp svneol=native#text/pascal
 tests/tbs/tbs0594.pp svneol=native#text/pascal
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain

+ 3 - 1
compiler/m68k/cgcpu.pas

@@ -1480,7 +1480,9 @@ unit cgcpu;
           ai.SetCondition(flags_to_cond(f));
           ai.SetCondition(flags_to_cond(f));
           list.concat(ai);
           list.concat(ai);
 
 
-          list.concat(taicpu.op_reg(A_EXTB,S_L,hreg));
+          { Scc stores a complete byte of 1s, but the compiler expects only one
+            bit set, so ensure this is the case }
+          list.concat(taicpu.op_const_reg(A_AND,S_L,1,hreg));
 
 
           if hreg<>reg then
           if hreg<>reg then
             begin
             begin

+ 11 - 0
tests/tbs/tb0601.pp

@@ -0,0 +1,11 @@
+program tb0601;
+
+var
+  i1, i2, i3: LongWord;
+begin
+  i1 := 42;
+  i2 := 84;
+  i3 := LongWord(i1 < i2);
+  if i3 <> 1 then
+    Halt(1);
+end.