Fixed endianness issue in script VM

See https://forum.zdoom.org/viewtopic.php?t=54549
This commit is contained in:
alexey.lysiuk 2016-12-26 15:59:44 +02:00 committed by Christoph Oelckers
parent 7f72de6b71
commit aeee80c8fa

View file

@ -21,27 +21,35 @@ typedef VM_UBYTE VM_ATAG;
#define VM_EPSILON (1/65536.0)
#ifdef __BIG_ENDIAN__
#define VM_DEFINE_OP2(TYPE, ARG1, ARG2) TYPE ARG2, ARG1
#define VM_DEFINE_OP4(TYPE, ARG1, ARG2, ARG3, ARG4) TYPE ARG4, ARG3, ARG2, ARG1
#else // little endian
#define VM_DEFINE_OP2(TYPE, ARG1, ARG2) TYPE ARG1, ARG2
#define VM_DEFINE_OP4(TYPE, ARG1, ARG2, ARG3, ARG4) TYPE ARG1, ARG2, ARG3, ARG4
#endif // __BIG_ENDIAN__
union VMOP
{
struct
{
VM_UBYTE op, a, b, c;
VM_DEFINE_OP4(VM_UBYTE, op, a, b, c);
};
struct
{
VM_SBYTE pad0, as, bs, cs;
VM_DEFINE_OP4(VM_SBYTE, pad0, as, bs, cs);
};
struct
{
VM_SWORD pad1:8, i24:24;
VM_DEFINE_OP2(VM_SWORD, pad1:8, i24:24);
};
struct
{
VM_SWORD pad2:16, i16:16;
VM_DEFINE_OP2(VM_SWORD, pad2:16, i16:16);
};
struct
{
VM_UHALF pad3, i16u;
VM_DEFINE_OP2(VM_UHALF, pad3, i16u);
};
VM_UWORD word;
@ -56,6 +64,9 @@ union VMOP
// sar eax,10h
};
#undef VM_DEFINE_OP4
#undef VM_DEFINE_OP2
enum
{
#include "vmops.h"