()
| 115 | |
| 116 | #[test] |
| 117 | fn decode_sw() { |
| 118 | // Sw::new(base, src, offset) |
| 119 | let encoded = Sw::new(6, 7, -8).encode(); |
| 120 | let decoded = decode(encoded).expect("should decode SW"); |
| 121 | if let DecodedInsn::Store { |
| 122 | funct3, |
| 123 | rs1, |
| 124 | rs2, |
| 125 | imm, |
| 126 | } = decoded |
| 127 | { |
| 128 | assert_eq!(funct3, 2, "SW funct3 must be 2"); |
| 129 | assert_eq!(rs1, 6); |
| 130 | assert_eq!(rs2, 7); |
| 131 | assert_eq!(imm, -8); |
| 132 | } else { |
| 133 | panic!("expected DecodedInsn::Store, got {decoded:?}"); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | #[test] |
| 138 | fn decode_beq() { |