libc8
CHIP-8 utility library
decode.h File Reference
#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)
 

Detailed Description

Stuff for disassembling bytecode.

Macro Definition Documentation

◆ C8_DECODE_DEFINE_LABELS

#define C8_DECODE_DEFINE_LABELS   0x1

◆ C8_DECODE_PRINT_ADDRESSES

#define C8_DECODE_PRINT_ADDRESSES   0x2

Function Documentation

◆ c8_decode()

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.

Parameters
inputthe CHIP-8 ROM file to disassemble
outputthe file to write the assembly to
args0 with ARG_PRINT_ADDRESSES and/or ARG_DEFINE_LABELS optionally OR'd

◆ c8_decode_instruction()

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.

Parameters
inThe instruction to decode
label_mapThe label map (can be NULL for no labels)
Returns
result containing the associated assembly instruction

◆ c8_jump()

uint16_t c8_jump ( uint16_t  )