From dc04a8a67740a8a0362ad33774aec4b53ccc9e45 Mon Sep 17 00:00:00 2001 From: Pierre Muller <pierre@freepascal.org> Date: Fri, 21 Apr 2023 10:32:13 +0100 Subject: [PATCH] Fix storing of unaligned 64-bit to memory --- compiler/mips/cgcpu.pas | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/compiler/mips/cgcpu.pas b/compiler/mips/cgcpu.pas index 02c1bddd09..90810fd128 100644 --- a/compiler/mips/cgcpu.pas +++ b/compiler/mips/cgcpu.pas @@ -1765,24 +1765,13 @@ begin tcgmips(cg).make_simple_ref(list,tmpref); if (ref.alignment <4) then begin - if target_info.endian = endian_little then + if target_info.endian = endian_big then begin inc(tmpref.offset,7); - incr:=-1; + incr:=-1; end else incr:=1; - list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref)); - Inc(tmpref.offset,incr); - list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reghi,reg.reghi,8)); - list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref)); - Inc(tmpref.offset,incr); - list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reghi,reg.reghi,8)); - list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref)); - Inc(tmpref.offset,incr); - list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reghi,reg.reghi,8)); - list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref)); - Inc(tmpref.offset,incr); list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref)); Inc(tmpref.offset,incr); list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reglo,reg.reglo,8)); @@ -1794,6 +1783,16 @@ begin list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reglo,reg.reglo,8)); list.concat(taicpu.op_reg_ref(A_SB,reg.reglo,tmpref)); Inc(tmpref.offset,incr); + list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref)); + Inc(tmpref.offset,incr); + list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reghi,reg.reghi,8)); + list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref)); + Inc(tmpref.offset,incr); + list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reghi,reg.reghi,8)); + list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref)); + Inc(tmpref.offset,incr); + list.concat(taicpu.op_reg_reg_const(A_SRL,reg.reghi,reg.reghi,8)); + list.concat(taicpu.op_reg_ref(A_SB,reg.reghi,tmpref)); end else begin