|
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 |
| Auto-generate label names. | |
| #define | C8_DECODE_PRINT_ADDRESSES 0x2 |
| Print addresses for each instruction. | |
Functions | |
| void | c8_decode (FILE *, FILE *, int) |
Convert bytecode from input to assembly and writes it to output. | |
| char * | c8_decode_instruction (uint16_t, uint8_t *) |
Decode in and return its assembly value. | |
| uint16_t | c8_jump (uint16_t) |
Stuff for disassembling bytecode.
| #define C8_DECODE_DEFINE_LABELS 0x1 |
Auto-generate label names.
| #define C8_DECODE_PRINT_ADDRESSES 0x2 |
Print addresses for each instruction.
| void c8_decode | ( | FILE * | input, |
| FILE * | output, | ||
| int | args | ||
| ) |
Convert bytecode from input to assembly and writes it to output.
C8_DECODE_PRINT_ADDRESSES should be AND'd to args to print addresses before each assembly instruction.
C8_DECODE_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 C8_DECODE_PRINT_ADDRESSES and/or C8_DECODE_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 | ) |