From 5e9cc3193c19fdd0d32bbc05c827ce752e17e5b3 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 16 Oct 2020 16:41:12 -0700 Subject: [PATCH] add cmprb_0 --- src/instr_models.rs | 16 ++++++++++++++++ src/lib.rs | 6 ++++++ src/main.rs | 15 +++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/instr_models.rs b/src/instr_models.rs index dd8c037..069e58e 100644 --- a/src/instr_models.rs +++ b/src/instr_models.rs @@ -850,3 +850,19 @@ pub fn cmplw(inputs: InstructionInput) -> InstructionResult { ..InstructionOutput::default() }) } + +pub fn cmprb_0(inputs: InstructionInput) -> InstructionResult { + let ra = inputs.try_get_ra()? as u8; + let rb: u64 = inputs.try_get_rb()?; + let eq = ra >= rb as u8 && ra <= (rb >> 8) as u8; + let cr0 = ConditionRegister { + lt: false, + gt: false, + eq, + so: false, + }; + Ok(InstructionOutput { + cr0: Some(cr0), + ..InstructionOutput::default() + }) +} diff --git a/src/lib.rs b/src/lib.rs index 940dfde..d544724 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -837,6 +837,12 @@ instructions! { fn cmplw(Ra, Rb, Overflow) -> (CR0) { "cmplw" } + + // cmprb 0, 0, ..., ... + #[enumerant = CmpRB0] + fn cmprb_0(Ra, Rb) -> (CR0) { + "cmprb 0, 0," + } } // must be after instrs macro call since it uses a macro definition diff --git a/src/main.rs b/src/main.rs index bf421d6..2b48024 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,6 +26,21 @@ const TEST_VALUES: &[u64] = &[ 0x7FFF, 0x8000, 0x8001, + // picked for cmprb + 0xFFED_CBA9_8765_4321, + // last byte of next 12 tests limits of ranges for cmprb + 0x85AE_16A6_0C1A_0E1F, + 0xCF24_50C7_9E7E_DF20, + 0xD486_2724_930B_9021, + 0xDDBA_3880_8588_DF42, + 0x1F07_F322_68FE_5C43, + 0x739D_46C6_1E05_AE44, + 0xA131_E014_B201_9064, + 0xC70D_BC09_C48A_C665, + 0x1D61_5696_5920_E966, + 0x70F1_F260_8938_4486, + 0xEF25_5D74_1B45_CA87, + 0x3C54_DFA8_C006_5688, ]; const IMMED16_TEST_VALUES: &[u16] = &[ -- 2.30.2