Browse Source

* correctly handle negative paraloc shift values for non power-of-2 sized
paralocs (e.g. a 3 byte record) in case the data's size has been
rounded up to the next power of two as far as the paraloc is concerned
(because those 3 bytes had to be shifted to be located in the upper 3
bytes of a 4 byte location)

git-svn-id: trunk@32633 -

Jonas Maebe 9 years ago
parent
commit
1320d6bdba
1 changed files with 5 additions and 1 deletions
  1. 5 1
      compiler/cgobj.pas

+ 5 - 1
compiler/cgobj.pas

@@ -1096,8 +1096,12 @@ implementation
                cgsize:=paraloc.size;
                cgsize:=paraloc.size;
                if paraloc.shiftval>0 then
                if paraloc.shiftval>0 then
                  a_op_const_reg_reg(list,OP_SHL,OS_INT,paraloc.shiftval,paraloc.register,paraloc.register)
                  a_op_const_reg_reg(list,OP_SHL,OS_INT,paraloc.shiftval,paraloc.register,paraloc.register)
+               { in case the original size was 3 or 5/6/7 bytes, the value was
+                 shifted to the top of the to 4 resp. 8 byte register on the
+                 caller side and needs to be stored with those bytes at the
+                 start of the reference -> don't shift right }
                else if (paraloc.shiftval<0) and
                else if (paraloc.shiftval<0) and
-                       (sizeleft in [1,2,4]) then
+                       ((-paraloc.shiftval) in [1,2,4]) then
                  begin
                  begin
                    a_op_const_reg_reg(list,OP_SHR,OS_INT,-paraloc.shiftval,paraloc.register,paraloc.register);
                    a_op_const_reg_reg(list,OP_SHR,OS_INT,-paraloc.shiftval,paraloc.register,paraloc.register);
                    { convert to a register of 1/2/4 bytes in size, since the
                    { convert to a register of 1/2/4 bytes in size, since the