ivg/bap — pull request #3 by rvantonder (2014-12-09 00:51:53+00:00)
Title: add initial dis utility

So to build it needs `-pkg cmdliner`, but you said not to add it to bapbuild (and so I didn't add it to oasis). Please comment on any style things that come up, e.g. I don't know if `@@` or `(foo bar)` styles are better. You will probably spot many things :)

Currently
```
OPTIONS
-a ARCH, --arch=ARCH (absent=x86_64)
Target architecture.

-c, --code
Output instruction code.

--help[=FMT] (default=pager)
Show this help in format FMT (pager, plain or groff).

-k, --kinds
Output instruction kinds.

-p, --ops
Output instruction opcode information.
```

Example inputs:
```
echo "0x48 0x83 0xec 0x08 0xe8 0x47 0xee 0xff 0xff 0x8b 0x40 0x10 0x48 0x83 0xc4 0x08 0xc3" | ./dis.native -pck
echo "\x48\x83\xec\x08\xe8\x47\xee\xff\xff\x8b\x40\x10\x48\x83\xc4\x08\xc3" | ./dis.native -pck
echo "48 83 ec 08 e8 47 ee ff ff 8b 40 10 48 83 c4 08 c3" | ./dis.native -pck

echo "c5 01 30 43" | ./dis.native --arch=arm -pck
echo "\xc5\x01\x30\x43" | ./dis.native -a arm -pck
echo "c5 01 30 43" | ./dis.native -aarm -pck
```

Example output (by the way tab width is greater on terminal, will look a little different (extra information columns are spaced farther away from disassembly)
x86_64
```
subq	$8, %rsp
|insn:2691
|reg:RSP:44
|reg:RSP:44
|imm:8
|kinds:may_load, may_store
callq	-4537
|insn:390
|imm:-4537
|kinds:call, may_affect_control_flow, may_load, may_store
movl	16(%rax), %eax
|insn:1579
|reg:EAX:19
|reg:RAX:35
|imm:1
|reg:nil:0
|imm:16
|reg:nil:0
|kinds:may_load, may_store
addq	$8, %rsp
|insn:99
|reg:RSP:44
|reg:RSP:44
|imm:8
|kinds:may_load, may_store
ret
|insn:2321
|kinds:return, barrier, terminator, may_affect_control_flow, may_load, may_store
```
Other thought: kinds can wrap-around on terminal, maybe there's a better way to represent it...

ARM
```
teqmi	r0, #1073741873
|insn:513
|reg:R0:66
|imm:1073741873
|imm:4
|reg:CPSR:3
|kinds:may_load, may_store
```