浏览代码

* big endian fix for second_int_to_int

Jonas Maebe 23 年之前
父节点
当前提交
fcec3ae6b0
共有 1 个文件被更改,包括 15 次插入5 次删除
  1. 15 5
      compiler/ncgcnv.pas

+ 15 - 5
compiler/ncgcnv.pas

@@ -64,7 +64,7 @@ interface
       cutils,verbose,
       cutils,verbose,
       aasmbase,aasmtai,aasmcpu,symconst,symdef,paramgr,
       aasmbase,aasmtai,aasmcpu,symconst,symdef,paramgr,
       ncon,ncal,
       ncon,ncal,
-      cpubase,cpuinfo,cpupara,
+      cpubase,cpuinfo,cpupara,systems,
       pass_2,
       pass_2,
       cginfo,cgbase,
       cginfo,cgbase,
       cgobj,cgcpu,
       cgobj,cgcpu,
@@ -76,6 +76,7 @@ interface
     procedure tcgtypeconvnode.second_int_to_int;
     procedure tcgtypeconvnode.second_int_to_int;
       var
       var
         newsize : tcgsize;
         newsize : tcgsize;
+        ressize, leftsize: cardinal;
       begin
       begin
         newsize:=def_cgsize(resulttype.def);
         newsize:=def_cgsize(resulttype.def);
 
 
@@ -84,14 +85,20 @@ interface
           cg.g_rangecheck(exprasmlist,left,resulttype.def);
           cg.g_rangecheck(exprasmlist,left,resulttype.def);
 
 
         { is the result size smaller ? }
         { is the result size smaller ? }
-        if resulttype.def.size<>left.resulttype.def.size then
+        ressize := resulttype.def.size;
+        leftsize := left.resulttype.def.size;
+        if ressize<>leftsize then
           begin
           begin
             location_copy(location,left.location);
             location_copy(location,left.location);
             { reuse a loc_reference when the newsize is smaller than
             { reuse a loc_reference when the newsize is smaller than
               than the original, else load it to a register }
               than the original, else load it to a register }
             if (location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and
             if (location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and
-               (resulttype.def.size<left.resulttype.def.size) then
-             location.size:=newsize
+               (ressize<leftsize) then
+             begin
+               location.size:=newsize;
+               if (target_info.endian = ENDIAN_BIG) then
+                 inc(location.reference.offset,leftsize-ressize);
+             end
             else
             else
              location_force_reg(exprasmlist,location,newsize,false);
              location_force_reg(exprasmlist,location,newsize,false);
           end
           end
@@ -496,7 +503,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.30  2002-09-07 15:25:02  peter
+  Revision 1.31  2002-09-16 13:08:44  jonas
+    * big endian fix for second_int_to_int
+
+  Revision 1.30  2002/09/07 15:25:02  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
   Revision 1.29  2002/09/02 18:46:00  peter
   Revision 1.29  2002/09/02 18:46:00  peter