Command line option specification
A toolset for a machine code decoder
usage: mcdecoder [-h] [--version] command ...
Positional Arguments
- command
Possible choices: generate, export, emulate, check
Named Arguments
- --version
show program’s version number and exit
Sub-commands
generate
Generate a decoder or other codes to support a decoder
mcdecoder generate [-h] [--type type | --template templatedir] [--output outdir] mcfile
Positional Arguments
- mcfile
A path to a machine code description file
Named Arguments
- --type
The type of a generator used for generating codes. Possible generators are:
c_decoder: Generating standard decoder API in C
athrill: Generating decoder API for athrill
The gererator ‘athrill’ is deprecated and will be removed in version 1.0
- --template
A path to a directoy including user-defined template files
- --output
A path to an output directory (default: .)
Default: “.”
Usage:
# Generate a decoder to 'out' directory
mcdecoder generate --output out mc.yaml
# Generate codes with the generator 'c_decoder'
mcdecoder generate --type c_decoder --output out mc.yaml
# Generate codes according to user-defined template files in 'user_templates' directory
mcdecoder generate --template user_templates --output out mc.yaml
export
Export an MC description as another format. Currently, mcdecoder only supports CSV format
mcdecoder export [-h] --output outfile mcfile
Positional Arguments
- mcfile
A path to a machine code description file
Named Arguments
- --output
A path to an output file
Usage:
# Export a MC description as CSV format
mcdecoder export --output mc.csv mc.yaml
emulate
Emulate a decoder by inputting binary data
mcdecoder emulate [-h] --input indata [--base {2,16}] [--byteorder {big,little}] mcfile
Positional Arguments
- mcfile
A path to a machine code description file
Named Arguments
- --input, --pattern
A binary/hex string as input binary data for a decoder. –pattern is deprecated and will be removed in version 1.0
- --base
Possible choices: 2, 16
The base of a binary/hex string (default: 16)
Default: 16
- --byteorder
Possible choices: big, little
The byte order of a binary/hex string (default: big)
Default: “big”
Usage:
# Emulate a decoder when inputting e92d4800
mcdecoder emulate --input e92d4800 mc.yaml
# Emulate a decoder when inputting '1110 1001 0010 1101 0100 1000 0000 0000'
mcdecoder emulate --base 2 --input '1110 1001 0010 1101 0100 1000 0000 0000' mc.yaml
# Emulate a decoder when inputting e92d4800 as little endian
mcdecoder emulate --byteorder little --input 00482de9 mc.yaml
check
Check the instruction validity of MC description by inputting binary data to a decoder
mcdecoder check [-h] --input indata [--base {2,16}] mcfile
Positional Arguments
- mcfile
A path to a machine code description file
Named Arguments
- --input, --pattern
A binary/hex string as input binary data for a decoder. ‘x’ character acts as a wildcard which corresponds to a range 0-1 for binary or 0-f for hex. –pattern is deprecated and will be removed in version 1.0
- --base
Possible choices: 2, 16
The base of a binary/hex string (default: 16)
Default: 16
Notes:
This command detects following problems:
No instructions are defined for a certain binary data
Duplicate instructions are defined for a certain binary data
Usage:
# Check by inputting the range from 092d4800 to f92d4800 to a decoder
mcdecoder check --input x92d4800 mc.yaml
# Check by inputting the range from '1010 1001 0010 1101 0100 1000 0000 0000' to '1110 1001 0010 1101 0100 1000 0000 0000' to a decoder
mcdecoder check --base 2 --input '1x10 1001 0010 1101 0100 1000 0000 0000' mc.yaml
# Check by inputting the range from 002d4800 to ff2d4800 to a decoder
mcdecoder check --input xx2d4800 mc.yaml