libc8
CHIP-8 utility library
|
#include <stdint.h>
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | C8_DECODE_DEFINE_LABELS 0x1 |
#define | C8_DECODE_PRINT_ADDRESSES 0x2 |
Functions | |
void | c8_decode (FILE *, FILE *, int) |
Convert bytecode from input to assembly and writes it to output . More... | |
char * | c8_decode_instruction (uint16_t, uint8_t *) |
Decode in and return its assembly value. More... | |
uint16_t | c8_jump (uint16_t) |
Stuff for disassembling bytecode.
#define C8_DECODE_DEFINE_LABELS 0x1 |
#define C8_DECODE_PRINT_ADDRESSES 0x2 |
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 c8_jump | ( | uint16_t | ) |