diff options
Diffstat (limited to '')
-rwxr-xr-x | tools/brainfuck/bf_decompile.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/brainfuck/bf_decompile.py b/tools/brainfuck/bf_decompile.py new file mode 100755 index 0000000..8caa97d --- /dev/null +++ b/tools/brainfuck/bf_decompile.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +import sys + +if len(sys.argv) < 2: + print("Give me filename...") + exit() + +bytecode = { + 0: '>', + 2: '<', + 7: '+', + 6: '-', + 5: '.', + 4: ',', + 3: '[', + 1: ']', +} + +bin_buff = open(sys.argv[1], mode="rb").read() +src_file = open(sys.argv[1]+".bf", mode="w") + +for b in bin_buff: + try: + c = bytecode[b & 0x07] + src_file.write(c) + except: + print("Error while processing file (aborting...)") + exit() + +src_file.close() |