From bd7cae741ca961ef6d5959bbf060205d9c514af0 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 10 Oct 2020 14:27:56 -0700 Subject: start getting display impls together, distinguish read/write operands --- tests/test.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test.rs b/tests/test.rs index cac89d0..a035c37 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -7,10 +7,35 @@ fn test_a_bundle() { // [MMI] addl r15=0,r1;; // ld8.acq r16=[r15],8 // mov r14=r1;; - let data = [0x0b, 0x78, 0x00, 0x02, 0x00, 0x24, 0x00, 0x41, 0x3c, 0x70, 0x27, 0xc0, 0x01, 0x08, 0x00, 0x84]; +// let data = [0x0b, 0x78, 0x00, 0x02, 0x00, 0x24, 0x00, 0x41, 0x3c, 0x70, 0x27, 0xc0, 0x01, 0x08, 0x00, 0x84]; + let data = [0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0]; + let data = [0x04, 0x10, 0x1c, 0x00, 0x80, 0x45, 0x02, 0x4c, 0x80, 0x09, 0x00, 0x60, 0xf0, 0x13, 0x1a, 0x60]; + let data = [0x05, 0x10, 0x41, 0x18, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x23, 0xc8, 0x6f]; let decoder = InstDecoder::default(); - decoder.decode(data[..].iter().cloned()).unwrap(); + let inst = decoder.decode(data[..].iter().cloned()).unwrap(); + println!("{:?}", inst); + println!("{}", inst); +} + +#[test] +fn test_br_cosmetics() { + let decoder = InstDecoder::default(); + + let data = [0x11, 0x08, 0x00, 0x1e, 0x18, 0x10, 0x60, 0x80, 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00]; + let inst = decoder.decode(data[..].iter().cloned()).unwrap(); + let stringy = format!("{}", inst); +// assert_eq!(stringy, "[MIB] ld8 r1=[r15]; mov b6=r16; br.few b6;;"); + + let data = [0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0]; + let inst = decoder.decode(data[..].iter().cloned()).unwrap(); + let stringy = format!("{}", inst); +// assert_eq!(stringy, "[MLX] nop.m 0; brl.sptk.few tgt;;"); + + let data = [0x19, 0x50, 0x40, 0x19, 0x3f, 0x23, 0x80, 0x00, 0x00, 0x00, 0x48, 0x80, 0x00, 0x00, 0x84, 0x02]; + let inst = decoder.decode(data[..].iter().cloned()).unwrap(); + let stringy = format!("{}", inst); + assert_eq!(stringy, "[MMB] adds r10=-48,r12; mov r8=0; br.ret.dptk.few b0"); } // from elf64-ia64-vms.c -- cgit v1.1