f0e4d8b54abb2d19ead94757e3858949d7819cf8
1 #ifndef DCPU16_H_3XXIQQG2
2 #define DCPU16_H_3XXIQQG2
4 /* the target system's concept of a word */
5 typedef unsigned short DCPU16_WORD
;
7 /* how much ram the system has */
8 #define DCPU16_RAM 0x10000
10 /* a self-contained dcpu16 core */
12 unsigned long long cycle
; /* number of cycles this core has executed */
13 DCPU16_WORD reg
[8]; /* system registers, a b c x y z i j */
14 DCPU16_WORD pc
; /* program counter */
15 DCPU16_WORD sp
; /* stack pointer */
16 DCPU16_WORD o
; /* overflow */
17 unsigned int skip_
: 1; /* skip execution of next instruction */
18 DCPU16_WORD ram
[DCPU16_RAM
]; /* memory */
19 DCPU16_WORD reg_work_
[2]; /* (private) work registers for holding literal values while decoding instructions */
22 /* instantiate a new core */
23 struct dcpu16
*dcpu16_new(void);
25 /* print the current state of a core */
26 void dcpu16_state_print(struct dcpu16
*);
28 /* print the contents of ram from second to third argument */
29 void dcpu16_dump_ram(struct dcpu16
*, DCPU16_WORD
, DCPU16_WORD
);
31 /* print the instruction at the specified address */
32 void dcpu16_disassemble_print(struct dcpu16
*, DCPU16_WORD
);
35 /* execute the next instruction */
36 void dcpu16_step(struct dcpu16
*);
39 void dcpu16_delete(struct dcpu16
**);
41 /* register callbacks to handle warning and debug messages, defaults to writing to stderr */
42 void dcpu16_warn_cb_set(void (*)(char *, ...));
43 void dcpu16_trace_cb_set(void (*)(char *, ...));
45 #endif /* DCPU16_H_3XXIQQG2 */