From 2b4f0734957d04490c28d2ab93cd376a5616c968 Mon Sep 17 00:00:00 2001
From: Christian Bay <christian.bay@studium.fau.de>
Date: Sat, 21 Nov 2015 22:17:12 +0100
Subject: [PATCH] CPU: Remove negation in cpu_decode_rm condition

---
 vm/comp/instructionBlocks/cpu_addInst.c     | 10 +++++-----
 vm/comp/instructionBlocks/cpu_compareInst.c |  8 ++++----
 vm/comp/instructionBlocks/cpu_moveInst.c    |  8 ++++----
 vm/comp/instructionBlocks/cpu_special0xC6.c |  2 +-
 vm/comp/instructionBlocks/cpu_special0xC7.c |  2 +-
 vm/comp/instructionBlocks/cpu_special0xFE.c |  4 ++--
 vm/comp/instructionBlocks/cpu_special0xFF.c |  6 +++---
 vm/comp/instructionBlocks/cpu_specialInst.c | 14 +++++++-------
 vm/comp/instructionBlocks/cpu_xorInst.c     | 10 +++++-----
 9 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/vm/comp/instructionBlocks/cpu_addInst.c b/vm/comp/instructionBlocks/cpu_addInst.c
index cc9e442..e0a8c40 100644
--- a/vm/comp/instructionBlocks/cpu_addInst.c
+++ b/vm/comp/instructionBlocks/cpu_addInst.c
@@ -1,6 +1,6 @@
 case 0x00:{
 	/*ADD r/m8 r8.*/
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t op1;
 		if(s_op.regmem_type == MEMORY)
 			op1 = cpu_read_byte_from_mem(cpu_state, s_op.regmem_mem);
@@ -27,7 +27,7 @@ case 0x00:{
 
 case 0x01:{
 	/*r/ADD m32 r32.*/
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t op1;
 		if(s_op.regmem_type == MEMORY)
 			op1 = cpu_read_word_from_mem(cpu_state, s_op.regmem_mem);
@@ -54,7 +54,7 @@ case 0x01:{
 
 case 0x02:{
 	/*ADD r8 r/m8.*/
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t op1 = cpu_read_byte_from_reg(s_op.reg, IS_HIGH(s_op.reg));
 		uint8_t op2;
 		if(s_op.regmem_type == MEMORY)
@@ -78,7 +78,7 @@ case 0x02:{
 
 case 0x03:{
 	/*ADD r32 r/m32.*/
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t op1 = cpu_read_word_from_reg(s_op.reg);
 		uint32_t op2;
 		if(s_op.regmem_type == MEMORY)
@@ -132,4 +132,4 @@ case 0x05: {
 
 //case 0x80 0 is a special case, see cpu_special0x80.c
 //case 0x81 0 is a special case, see cpu_special0x81.c
-//case 0x83 0 is a special case, see cpu_special0x83.c
\ No newline at end of file
+//case 0x83 0 is a special case, see cpu_special0x83.c
diff --git a/vm/comp/instructionBlocks/cpu_compareInst.c b/vm/comp/instructionBlocks/cpu_compareInst.c
index 4d02ecd..6eadf0c 100644
--- a/vm/comp/instructionBlocks/cpu_compareInst.c
+++ b/vm/comp/instructionBlocks/cpu_compareInst.c
@@ -22,7 +22,7 @@ case 0x3D: {
 
 case 0x38: {
 	/*Compare r8 with r/m8. */
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t minuend, subtrahend;
 
 		subtrahend = cpu_read_byte_from_reg(s_op.reg, IS_HIGH(s_op.reg));
@@ -40,7 +40,7 @@ case 0x38: {
 }
 case 0x39: {
 	/*Compare r32 with r/m32. */
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t minuend, subtrahend;
 
 		subtrahend = cpu_read_word_from_reg(s_op.reg);
@@ -58,7 +58,7 @@ case 0x39: {
 }
 case 0x3A: {
 	/* Compare r/m8 with r8. */
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t minuend, subtrahend;
 
 		minuend = cpu_read_byte_from_reg(s_op.reg, IS_HIGH(s_op.reg));
@@ -77,7 +77,7 @@ case 0x3A: {
 
 case 0x3B: {
 	/* Compare r/m32 with r32. */
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t minuend, subtrahend;
 
 		minuend = cpu_read_word_from_reg(s_op.reg);
diff --git a/vm/comp/instructionBlocks/cpu_moveInst.c b/vm/comp/instructionBlocks/cpu_moveInst.c
index 2905f2f..aae1aaf 100644
--- a/vm/comp/instructionBlocks/cpu_moveInst.c
+++ b/vm/comp/instructionBlocks/cpu_moveInst.c
@@ -1,6 +1,6 @@
 case 0x88: {
 	/* Copy r8 to r/m8 */
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t src = cpu_read_byte_from_reg(s_op.reg, IS_HIGH(s_op.reg));
 		if(s_op.regmem_type == MEMORY){
 			cpu_write_byte_in_mem(cpu_state, src, s_op.regmem_mem);
@@ -13,7 +13,7 @@ case 0x88: {
 }
 case 0x89: {
 	/* Copy r32 to r/m32 */
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t src = cpu_read_word_from_reg(s_op.reg);
 		if(s_op.regmem_type == MEMORY){
 			cpu_write_word_in_mem(cpu_state, src, s_op.regmem_mem);
@@ -27,7 +27,7 @@ case 0x89: {
 
 case 0x8A: {
 	/* Copy r/m8 to r8. */
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t src;
 		if(s_op.regmem_type == MEMORY){
 			src = cpu_read_byte_from_mem(cpu_state, s_op.regmem_mem);
@@ -42,7 +42,7 @@ case 0x8A: {
 
 case 0x8B: {
 	/* Copy r/m32 to r32. */
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t src;
 		if(s_op.regmem_type == MEMORY){
 			src = cpu_read_word_from_mem(cpu_state, s_op.regmem_mem);
diff --git a/vm/comp/instructionBlocks/cpu_special0xC6.c b/vm/comp/instructionBlocks/cpu_special0xC6.c
index 7503fd5..76d5f31 100644
--- a/vm/comp/instructionBlocks/cpu_special0xC6.c
+++ b/vm/comp/instructionBlocks/cpu_special0xC6.c
@@ -1,6 +1,6 @@
 case 0: {
 	/* Copy imm8 to r/m8. */
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t src = cpu_consume_byte_from_mem(cpu_state);
 		if(s_op.regmem_type == MEMORY){
 			cpu_write_byte_in_mem(cpu_state, src, s_op.regmem_mem);
diff --git a/vm/comp/instructionBlocks/cpu_special0xC7.c b/vm/comp/instructionBlocks/cpu_special0xC7.c
index 84e76f5..4fc9a36 100644
--- a/vm/comp/instructionBlocks/cpu_special0xC7.c
+++ b/vm/comp/instructionBlocks/cpu_special0xC7.c
@@ -1,6 +1,6 @@
 case 0: {
 	/* Copy imm32 to r/m32. */
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint8_t src = cpu_consume_word_from_mem(cpu_state);
 		if(s_op.regmem_type == MEMORY){
 			cpu_write_word_in_mem(cpu_state, src, s_op.regmem_mem);
diff --git a/vm/comp/instructionBlocks/cpu_special0xFE.c b/vm/comp/instructionBlocks/cpu_special0xFE.c
index 887eddd..a0af957 100644
--- a/vm/comp/instructionBlocks/cpu_special0xFE.c
+++ b/vm/comp/instructionBlocks/cpu_special0xFE.c
@@ -1,6 +1,6 @@
 case 0: {
 	/* Increment r/m byte by 1 */
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t src;
 		if(s_op.regmem_type == MEMORY){
 			src = cpu_read_byte_from_mem(cpu_state, s_op.regmem_mem);
@@ -18,7 +18,7 @@ case 0: {
 
 case 1: {
 	/* Decrement r/m byte by 1 */
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t src;
 		if(s_op.regmem_type == MEMORY){
 			src = cpu_read_byte_from_mem(cpu_state, s_op.regmem_mem);
diff --git a/vm/comp/instructionBlocks/cpu_special0xFF.c b/vm/comp/instructionBlocks/cpu_special0xFF.c
index 22bac1b..8fb91cf 100644
--- a/vm/comp/instructionBlocks/cpu_special0xFF.c
+++ b/vm/comp/instructionBlocks/cpu_special0xFF.c
@@ -1,6 +1,6 @@
 case 0: {
 	/* Increment r/m word by 1 */
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t src;
 		if(s_op.regmem_type == MEMORY){
 			src = cpu_read_word_from_mem(cpu_state, s_op.regmem_mem);
@@ -17,7 +17,7 @@ case 0: {
 }
 case 1: {
 	/* Decrement r/m word by 1 */
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t src;
 		if(s_op.regmem_type == MEMORY){
 			src = cpu_read_word_from_mem(cpu_state, s_op.regmem_mem);
@@ -41,7 +41,7 @@ case 3: {
 }
 case 4: {
 	/* jump near, absolute indirect, address given in r/m32 (r). */
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		cpu_set_eip(cpu_state, cpu_read_word_from_reg(s_op.regmem_reg));
 		return true;
 	}
diff --git a/vm/comp/instructionBlocks/cpu_specialInst.c b/vm/comp/instructionBlocks/cpu_specialInst.c
index 2f89286..c4dd9d1 100644
--- a/vm/comp/instructionBlocks/cpu_specialInst.c
+++ b/vm/comp/instructionBlocks/cpu_specialInst.c
@@ -9,7 +9,7 @@ case 0x0f: {
 case 0x80: {
 	/* Special case: Specific instruction decoded in Mod/RM byte */
 
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		switch(s_op.reg_value){
 			#include "cpu_special0x80.c"
 		}
@@ -20,7 +20,7 @@ case 0x80: {
 case 0x81: {
 	/* Special case: Specific instruction decoded in Mod/RM byte */
 
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		switch(s_op.reg_value){
 			#include "cpu_special0x81.c"
 		}
@@ -31,7 +31,7 @@ case 0x81: {
 case 0x83: {
 	/* Special case: Specific instruction decoded in Mod/RM byte */
 
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		switch(s_op.reg_value){
 			#include "cpu_special0x83.c"
 		}
@@ -42,7 +42,7 @@ case 0x83: {
 case 0xC6: {
 	/* Special case: Specific instruction decoded in Mod/RM byte */
 
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		switch(s_op.reg_value){
 			#include "cpu_special0xC6.c"
 		}
@@ -53,7 +53,7 @@ case 0xC6: {
 case 0xC7: {
 	/* Special case: Specific instruction decoded in Mod/RM byte */
 
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		switch(s_op.reg_value){
 			#include "cpu_special0xC7.c"
 		}
@@ -64,10 +64,10 @@ case 0xC7: {
 case 0xFF: {
 	/* Special case: Specific instruction decoded in Mod/RM byte */
 
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		switch(s_op.reg_value){
 			#include "cpu_special0xFF.c"
 		}
 	}
 	break;
-}
\ No newline at end of file
+}
diff --git a/vm/comp/instructionBlocks/cpu_xorInst.c b/vm/comp/instructionBlocks/cpu_xorInst.c
index 44ef049..9090f6c 100644
--- a/vm/comp/instructionBlocks/cpu_xorInst.c
+++ b/vm/comp/instructionBlocks/cpu_xorInst.c
@@ -1,6 +1,6 @@
 case 0x30:{
 	/*r/m8 XOR r8.*/
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t src;
 		if(s_op.regmem_type == MEMORY)
 			src = cpu_read_byte_from_mem(cpu_state, s_op.regmem_mem);
@@ -27,7 +27,7 @@ case 0x30:{
 
 case 0x31:{
 	/*r/m32 XOR r32.*/
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t op1;
 		if(s_op.regmem_type == MEMORY)
 			op1 = cpu_read_word_from_mem(cpu_state, s_op.regmem_mem);
@@ -54,7 +54,7 @@ case 0x31:{
 
 case 0x32:{
 	/*r8 XOR r/m8.*/
-	if(!cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, EIGHT_BIT)){
 		uint8_t op1 = cpu_read_byte_from_reg(s_op.reg, IS_HIGH(s_op.reg));
 		uint8_t op2;
 		if(s_op.regmem_type == MEMORY)
@@ -78,7 +78,7 @@ case 0x32:{
 
 case 0x33:{
 	/*r32 XOR r/m32.*/
-	if(!cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
+	if(cpu_decode_RM(cpu_state, &s_op, !EIGHT_BIT)){
 		uint32_t op1 = cpu_read_word_from_reg(s_op.reg);
 		uint32_t op2;
 		if(s_op.regmem_type == MEMORY)
@@ -133,4 +133,4 @@ case 0x35:{
 
 //case 0x80 /6 is a special instruction, see cpu_special0x80.c
 //case 0x81 /6 is a special instruction, see cpu_special0x81.c
-//case 0x83 /6 is a special instruction, see cpu_special0x83.c
\ No newline at end of file
+//case 0x83 /6 is a special instruction, see cpu_special0x83.c
-- 
GitLab