32 lines
757 B
C
32 lines
757 B
C
#ifndef BF_EMULATOR_H_
|
|
#define BF_EMULATOR_H_
|
|
|
|
#include <inttypes.h>
|
|
#include <stdlib.h>
|
|
|
|
enum bf_step_result {
|
|
BF_STEP_OK,
|
|
BF_STEP_FINISHED,
|
|
BF_STEP_ERROR,
|
|
};
|
|
|
|
struct bf_emulator {
|
|
uint32_t data_pointer;
|
|
|
|
void *data;
|
|
uint32_t data_len;
|
|
uint32_t cell_size;
|
|
|
|
const char *program;
|
|
size_t program_len;
|
|
size_t program_pointer;
|
|
};
|
|
|
|
void bf_emulator_init(struct bf_emulator *emulator, uint32_t cell_size, uint32_t data_len);
|
|
void bf_emulator_deinit(struct bf_emulator *emulator);
|
|
enum bf_step_result bf_emulator_step(struct bf_emulator *emulator);
|
|
enum bf_step_result bf_emulator_continue(struct bf_emulator *emulator);
|
|
enum bf_step_result bf_emulator_run(struct bf_emulator *emulator, const char *program, size_t program_len);
|
|
|
|
#endif //BF_EMULATOR_H_
|