old-computer-simulator

godot game
git clone git://git.evenfri.xyz/old-computer-simulator.git
Log | Files | Refs

emu.h (1062B)


      1 #ifndef emu_h
      2 #define emu_h
      3 
      4 #include <stdlib.h>
      5 #include <stdint.h>
      6 #include <stdio.h>
      7 #include <string.h>
      8 
      9 #define reg_a 0b111
     10 #define reg_b 0b000
     11 #define reg_c 0b001
     12 #define reg_d 0b010
     13 #define reg_e 0b011
     14 #define reg_h 0b100
     15 #define reg_l 0b101
     16 #define reg_m 0b110
     17 
     18 #define op_n      0b00
     19 #define op_mv     0b01
     20 #define op_sum_a  0b10
     21 #define op_jmp    0b11
     22 
     23 #if defined(__GNUC__) || defined(__clang__)
     24   #define EXPORT __attribute__((visibility("default")))
     25 #else
     26   #define EXPORT
     27 #endif
     28 
     29 typedef struct emulator emulator;
     30 typedef unsigned char byte;
     31 
     32 #ifdef __cplusplus
     33 extern "C" {
     34 #endif
     35 
     36 EXPORT emulator* emu_create(void);
     37 EXPORT int emu_load_program(emulator *e, const char *filename);
     38 EXPORT void emu_destroy(emulator *e);
     39 EXPORT int emu_step(emulator *e);
     40 EXPORT void emu_mem_write(emulator *e, uint16_t addr, byte val);
     41 EXPORT byte emu_mem_read(emulator *e, uint16_t addr);
     42 EXPORT int emu_get_pc(emulator *e);
     43 EXPORT void emu_set_pc(emulator *e, int pc);
     44 EXPORT byte emu_get_reg(emulator *e, byte c);
     45 
     46 #ifdef __cplusplus
     47 }
     48 #endif
     49 
     50 #endif /* emu_h */