Let's check out how to use
AssemblyConverter. First, let's import it into our Python file:
We can now instantiate an object. The constructor's defaults are initialized as so:
output_type refers to whether a converted file should be outputted to an array(
"a"), a file (
"f"), or printed to console (
"p"). Here are acceptable usages:
nibble refers to whether (for file and console outputs) the 32-bit binary numbers should be split in nibbles or kept as an unbroken string. An example output for
nibble = True would be:
An example for the default
nibble = False would be:
hexMode gives the option (for text file, array outputs, and console outputs) to output in hexadecimal form instead of binary. By default, the outputs are in binary. Leading zeros are included to properly represent a 32-bit instruction.
With this object we can apply the key function :
convert(). This function takes in either a string with assembly in it or a file name (with
.s extension) from the local directory and converts it to the output format of your choice, specified by the object construction. Let's convert the file
Any empty files, fully commented files, or files without
.s extension will not be accepted.
Here are a few functions that might be useful.
AssemblyConverter has three properties:
nibble_mode , and
hex_mode. This makes getting/setting these values very accessible. Observe:
instructionExists(instr)returns a boolean for whether