From 241dc91982691c1c6c7c342c40f1812611268741 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 13 May 2019 11:45:46 -0700 Subject: . --- subx/015immediate_addressing.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'subx') diff --git a/subx/015immediate_addressing.cc b/subx/015immediate_addressing.cc index 7abf7951..30f96523 100644 --- a/subx/015immediate_addressing.cc +++ b/subx/015immediate_addressing.cc @@ -124,18 +124,19 @@ void test_subtract_imm32_from_eax() { case 0x2d: { // subtract imm32 from EAX const int32_t signed_arg2 = next32(); trace(Callstack_depth+1, "run") << "subtract imm32 0x" << HEXWORD << signed_arg2 << " from EAX" << end(); - int64_t signed_full_result = Reg[EAX].i - signed_arg2; - Reg[EAX].i -= signed_arg2; - trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); - SF = (Reg[EAX].i < 0); - ZF = (Reg[EAX].i == 0); - OF = (Reg[EAX].i != signed_full_result); + int32_t signed_result = Reg[EAX].i - signed_arg2; + SF = (signed_result < 0); + ZF = (signed_result == 0); + int64_t signed_full_result = static_cast(Reg[EAX].i) - signed_arg2; + OF = (signed_result != signed_full_result); // set CF uint32_t unsigned_arg2 = static_cast(signed_arg2); uint32_t unsigned_result = Reg[EAX].u - unsigned_arg2; - uint64_t unsigned_full_result = Reg[EAX].u - unsigned_arg2; + uint64_t unsigned_full_result = static_cast(Reg[EAX].u) - unsigned_arg2; CF = (unsigned_result != unsigned_full_result); trace(Callstack_depth+1, "run") << "SF=" << SF << "; ZF=" << ZF << "; CF=" << CF << "; OF=" << OF << end(); + Reg[EAX].i = signed_result; + trace(Callstack_depth+1, "run") << "storing 0x" << HEXWORD << Reg[EAX].i << end(); break; } -- cgit 1.4.1-2-gfad0