switch endian mode with cs_option() for Arm/Arm64/Mips/Sparc. fix issue #849
diff --git a/arch/AArch64/AArch64Module.c b/arch/AArch64/AArch64Module.c
index f44a7ea..ea9d0ce 100644
--- a/arch/AArch64/AArch64Module.c
+++ b/arch/AArch64/AArch64Module.c
@@ -38,6 +38,10 @@
 
 static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
 {
+	if (type == CS_OPT_MODE) {
+		handle->big_endian = (((cs_mode)value & CS_MODE_BIG_ENDIAN) != 0);
+	}
+
 	return CS_ERR_OK;
 }
 
diff --git a/arch/ARM/ARMModule.c b/arch/ARM/ARMModule.c
index 507a484..26b6192 100644
--- a/arch/ARM/ARMModule.c
+++ b/arch/ARM/ARMModule.c
@@ -52,6 +52,8 @@
 				handle->disasm = ARM_getInstruction;
 
 			handle->mode = (cs_mode)value;
+			handle->big_endian = ((handle->mode & CS_MODE_BIG_ENDIAN) != 0);
+
 			break;
 		case CS_OPT_SYNTAX:
 			ARM_getRegName(handle, (int)value);
diff --git a/arch/Mips/MipsModule.c b/arch/Mips/MipsModule.c
index 92887c3..0b4a60f 100644
--- a/arch/Mips/MipsModule.c
+++ b/arch/Mips/MipsModule.c
@@ -37,6 +37,7 @@
 {
 	if (type == CS_OPT_MODE) {
 		handle->mode = (cs_mode)value;
+		handle->big_endian = ((handle->mode & CS_MODE_BIG_ENDIAN) != 0);
 		return CS_ERR_OK;
 	}
 
diff --git a/arch/PowerPC/PPCModule.c b/arch/PowerPC/PPCModule.c
index 5f0aedd..a777a1b 100644
--- a/arch/PowerPC/PPCModule.c
+++ b/arch/PowerPC/PPCModule.c
@@ -40,6 +40,10 @@
 	if (type == CS_OPT_SYNTAX)
 		handle->syntax = (int) value;
 
+	if (type == CS_OPT_MODE) {
+		handle->big_endian = (((cs_mode)value & CS_MODE_BIG_ENDIAN) != 0);
+	}
+
 	return CS_ERR_OK;
 }
 
diff --git a/arch/Sparc/SparcModule.c b/arch/Sparc/SparcModule.c
index 8c921f0..b9c94ea 100644
--- a/arch/Sparc/SparcModule.c
+++ b/arch/Sparc/SparcModule.c
@@ -39,6 +39,10 @@
 	if (type == CS_OPT_SYNTAX)
 		handle->syntax = (int) value;
 
+	if (type == CS_OPT_MODE) {
+		handle->big_endian = (((cs_mode)value & CS_MODE_BIG_ENDIAN) != 0);
+	}
+
 	return CS_ERR_OK;
 }