From ce702df5264de939853ee92ac13f605be4fb5c71 Mon Sep 17 00:00:00 2001 From: Pierre Muller Date: Mon, 26 Feb 2024 17:34:48 +0100 Subject: [PATCH] Take care about endianess in arm instruction binary code generator --- compiler/arm/aasmcpu.pas | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/compiler/arm/aasmcpu.pas b/compiler/arm/aasmcpu.pas index a47639b85e..61eb32a82f 100644 --- a/compiler/arm/aasmcpu.pas +++ b/compiler/arm/aasmcpu.pas @@ -5835,7 +5835,23 @@ implementation bytes:=((bytes shr 16) and $FFFF) or ((bytes and $FFFF) shl 16); { we're finished, write code } - objdata.writebytes(bytes,bytelen); + if source_info.endian<>target_info.endian then + begin + if (bytelen=4) then + if target_info.endian=endian_little then + objdata.writeInt32LE(int32(bytes)) + else + objdata.writeInt32BE(int32(bytes)) + else if (bytelen=2) then + if target_info.endian=endian_little then + objdata.writeInt16LE(int32(bytes)) + else + objdata.writeInt16BE(int32(bytes)) + else + internalerror(2024022601); + end + else + objdata.writebytes(bytes,bytelen); end; begin