Procházet zdrojové kódy

* check left and right loc for 64 bit when assigning a constant, resolves #9145

git-svn-id: trunk@7925 -
florian před 18 roky
rodič
revize
e4524a0d26
3 změnil soubory, kde provedl 33 přidání a 3 odebrání
  1. 1 0
      .gitattributes
  2. 3 3
      compiler/ncgld.pas
  3. 29 0
      tests/webtbs/tw9145.pp

+ 1 - 0
.gitattributes

@@ -8333,6 +8333,7 @@ tests/webtbs/tw9113.pp svneol=native#text/plain
 tests/webtbs/tw9128.pp svneol=native#text/plain
 tests/webtbs/tw9139.pp svneol=native#text/plain
 tests/webtbs/tw9139a.pp svneol=native#text/plain
+tests/webtbs/tw9145.pp svneol=native#text/plain
 tests/webtbs/tw9162.pp svneol=native#text/plain
 tests/webtbs/tw9167.pp svneol=native#text/plain
 tests/webtbs/tw9174.pp svneol=native#text/plain

+ 3 - 3
compiler/ncgld.pas

@@ -659,11 +659,11 @@ implementation
               LOC_CONSTANT :
                 begin
 {$ifndef cpu64bit}
-                  if right.location.size in [OS_64,OS_S64] then
-                   cg64.a_load64_const_loc(current_asmdata.CurrAsmList,right.location.value64,left.location)
+                  if (left.location.size in [OS_64,OS_S64]) or (right.location.size in [OS_64,OS_S64]) then
+                    cg64.a_load64_const_loc(current_asmdata.CurrAsmList,right.location.value64,left.location)
                   else
 {$endif cpu64bit}
-                   cg.a_load_const_loc(current_asmdata.CurrAsmList,right.location.value,left.location);
+                    cg.a_load_const_loc(current_asmdata.CurrAsmList,right.location.value,left.location);
                 end;
               LOC_REFERENCE,
               LOC_CREFERENCE :

+ 29 - 0
tests/webtbs/tw9145.pp

@@ -0,0 +1,29 @@
+program main;
+{$mode objfpc}
+uses
+  ctypes;
+
+const
+  // CoProcessor registers
+  DIV_CR				    : pcuint16 = pointer($04000280);
+  DIV_NUMERATOR64		: pcint64  = pointer($04000290);
+  DIV_DENOMINATOR32	: pcint32  = pointer($04000298);
+  DIV_RESULT32		  : pcint32  = pointer($040002A0);
+  DIV_64_32 = 1;
+  DIV_BUSY	= (1 shl 15);
+
+function mydivf32(num: cint32; den: cint32): cint32; inline;
+begin
+	DIV_CR^ := DIV_64_32;
+	while (DIV_CR^ and DIV_BUSY) <> 0 do;
+	DIV_NUMERATOR64^ := cint64(num) shl 12;
+  DIV_DENOMINATOR32^ := den;
+	while (DIV_CR^ and DIV_BUSY) <> 0 do;
+	mydivf32 := DIV_RESULT32^;
+end;
+
+var
+  a: cint32;
+begin
+  a := mydivf32(10, 2);
+end.