ross-emulator 0.1.0

Emulator for the Rusty Old Smart System
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env python3
# pip3 install keystone-engine
#
# Example:
# $ ./asm.py < <(echo 'mov r0, #-1; bx lr')
# [0x4f, 0xf0, 0xff, 0x30, 0x70, 0x47]
from keystone import *
import sys
import fileinput

ks = Ks(KS_ARCH_ARM, keystone.KS_MODE_THUMB | keystone.KS_MODE_LITTLE_ENDIAN)
code = ''.join(fileinput.input())
encoded_asm, num_inst = ks.asm(code)
if not encoded_asm:
    raise RuntimeError("no assembly")
print('[', ', '.join([hex(b) for b in encoded_asm]), ']', sep='')