Loading basic_op/basop32.c +17 −8 Original line number Diff line number Diff line Loading @@ -171,17 +171,26 @@ Flag Carry = 0; #ifdef BASOP_NOGLOB #if defined BASOP_NOGLOB_DEV_ABORT #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) if ((error_enable) || (warning_enable)) { assert(0); } #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) do { if ((error_enable) || (warning_enable)) { assert(0); } } while(0) #elif defined BASOP_NOGLOB_DEV_PRINT #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) if (error_enable) { print_basop_noglob_error(); } else if (warning_enable) { print_basop_noglob_warning(); } #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) do { if (error_enable) { print_basop_noglob_error(); } else if (warning_enable) { print_basop_noglob_warning(); } } while(0) #else #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) (void)0; /* noop */ #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) do { (void)0; } while(0) /* no-op */ #endif void set_overflow(Flag *overflow) { if (overflow) *overflow = 1; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } } void unset_overflow(Flag* overflow) { if (overflow) *overflow = 0; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } } void set_carry(Flag *carry) { if (carry) *carry = 1; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } } void unset_carry(Flag* carry) { if (carry) *carry = 0; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } } Flag get_carry(Flag* carry) { if (carry) return *carry; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } return 0; } #ifdef BASOP_NOGLOB_DEV_USE_GLOBALS #define BASOP_SET_GLOBAL(global_flag, value) do { (global_flag) = (value); } while (0) #define BASOP_GET_GLOBAL(global_flag) (global_flag) #else #define BASOP_SET_GLOBAL(global_flag, value) do { (void)0; } while(0) /* no-op */ #define BASOP_GET_GLOBAL(global_flag) 0 /* Default to 0 */ #endif void set_overflow(Flag *overflow) { if (overflow) *overflow = 1; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); BASOP_SET_GLOBAL(Overflow, 1); } } void unset_overflow(Flag* overflow) { if (overflow) *overflow = 0; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); BASOP_SET_GLOBAL(Overflow, 0); } } void set_carry(Flag *carry) { if (carry) *carry = 1; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); BASOP_SET_GLOBAL(Carry, 1); } } void unset_carry(Flag* carry) { if (carry) *carry = 0; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); BASOP_SET_GLOBAL(Carry, 0);} } Flag get_carry(Flag* carry) { if (carry) return *carry; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } return BASOP_GET_GLOBAL(Carry); } #ifdef BASOP_NOGLOB_DEV_PRINT #include <stdio.h> Loading Loading
basic_op/basop32.c +17 −8 Original line number Diff line number Diff line Loading @@ -171,17 +171,26 @@ Flag Carry = 0; #ifdef BASOP_NOGLOB #if defined BASOP_NOGLOB_DEV_ABORT #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) if ((error_enable) || (warning_enable)) { assert(0); } #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) do { if ((error_enable) || (warning_enable)) { assert(0); } } while(0) #elif defined BASOP_NOGLOB_DEV_PRINT #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) if (error_enable) { print_basop_noglob_error(); } else if (warning_enable) { print_basop_noglob_warning(); } #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) do { if (error_enable) { print_basop_noglob_error(); } else if (warning_enable) { print_basop_noglob_warning(); } } while(0) #else #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) (void)0; /* noop */ #define BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(error_enable, warning_enable) do { (void)0; } while(0) /* no-op */ #endif void set_overflow(Flag *overflow) { if (overflow) *overflow = 1; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } } void unset_overflow(Flag* overflow) { if (overflow) *overflow = 0; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } } void set_carry(Flag *carry) { if (carry) *carry = 1; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } } void unset_carry(Flag* carry) { if (carry) *carry = 0; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } } Flag get_carry(Flag* carry) { if (carry) return *carry; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } return 0; } #ifdef BASOP_NOGLOB_DEV_USE_GLOBALS #define BASOP_SET_GLOBAL(global_flag, value) do { (global_flag) = (value); } while (0) #define BASOP_GET_GLOBAL(global_flag) (global_flag) #else #define BASOP_SET_GLOBAL(global_flag, value) do { (void)0; } while(0) /* no-op */ #define BASOP_GET_GLOBAL(global_flag) 0 /* Default to 0 */ #endif void set_overflow(Flag *overflow) { if (overflow) *overflow = 1; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); BASOP_SET_GLOBAL(Overflow, 1); } } void unset_overflow(Flag* overflow) { if (overflow) *overflow = 0; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); BASOP_SET_GLOBAL(Overflow, 0); } } void set_carry(Flag *carry) { if (carry) *carry = 1; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); BASOP_SET_GLOBAL(Carry, 1); } } void unset_carry(Flag* carry) { if (carry) *carry = 0; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); BASOP_SET_GLOBAL(Carry, 0);} } Flag get_carry(Flag* carry) { if (carry) return *carry; else { BASOP_TRIGGER_OVERFLOW_ERROR_OR_WARNING(overflow_error_enable, overflow_warning_enable); } return BASOP_GET_GLOBAL(Carry); } #ifdef BASOP_NOGLOB_DEV_PRINT #include <stdio.h> Loading