libc8
CHIP-8 utility library
|
Macros | |
#define | DEFINE_LABELS (args & C8_DECODE_DEFINE_LABELS) |
#define | PRINT_ADDRESSES (args & C8_DECODE_PRINT_ADDRESSES) |
Functions | |
void | c8_decode (FILE *input, FILE *output, int args) |
Convert bytecode from input to assembly and writes it to output . More... | |
char * | c8_decode_instruction (uint16_t in, uint8_t *label_map) |
Decode in and return its assembly value. More... | |
uint16_t | jump (uint16_t in) |
Returns the value to jump to if n is a jump instruction, or 0. More... | |
Variables | |
char | result [32] |
Stuff for disassembling bytecode.
#define DEFINE_LABELS (args & C8_DECODE_DEFINE_LABELS) |
#define PRINT_ADDRESSES (args & C8_DECODE_PRINT_ADDRESSES) |
void c8_decode | ( | FILE * | input, |
FILE * | output, | ||
int | args | ||
) |
Convert bytecode from input
to assembly and writes it to output
.
ARG_PRINT_ADDRESSES
should be AND'd to args to print addresses before each assembly instruction.
ARG_DEFINE_LABELS
should be AND'd to args to define labels.
input | the CHIP-8 ROM file to disassemble |
output | the file to write the assembly to |
args | 0 with ARG_PRINT_ADDRESSES and/or ARG_DEFINE_LABELS optionally OR'd |
char * c8_decode_instruction | ( | uint16_t | in, |
uint8_t * | label_map | ||
) |
Decode in
and return its assembly value.
Gets the assembly value of instruction in
, stores it in the global variable result
, and returns result
.
If label_map
is not NULL
, it should point to an aray of size MEMSIZE
, with all "labeled" elements set to a unique, non-zero integer. All other elements should be zero.
If label_map
is not NULL
, label_map[nnn]
is greater than 0, and the instruction contains a nnn argument, a label name will be generated and used in the resulting string.
in | The instruction to decode |
label_map | The label map (can be NULL for no labels) |
result
containing the associated assembly instruction uint16_t jump | ( | uint16_t | in | ) |
Returns the value to jump to if n
is a jump instruction, or 0.
in | The instruction to check |
in
's nnn
value if it exists, 0 otherwise. char result[32] |