add cmprb_0
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 16 Oct 2020 23:41:12 +0000 (16:41 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Fri, 16 Oct 2020 23:41:12 +0000 (16:41 -0700)
src/instr_models.rs
src/lib.rs
src/main.rs

index dd8c0373eee3e19229abf7801b82696564a455da..069e58e9200255af5dd71358daabce58ae40eaa8 100644 (file)
@@ -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()
+    })
+}
index 940dfde7bf705a91ae2c599e20a0b9ddc7681b6f..d5447245a45cda1a5c9cded5061becc13a0e0b43 100644 (file)
@@ -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
index bf421d6ddb872a534d47cb0668657f5a3a644bec..2b4802449a637e0b57f0b2169414e026be09ac7d 100644 (file)
@@ -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] = &[