-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
30 lines (28 loc) · 781 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include "z80.h"
/*
* The intercept function is invoked on each and every CPU instruction. It
* quits the simulation when the PC register reaches address #0005 by changing
* the virtual CPU status.
*/
static void intercept(void *ctx)
{
z80 *cpu = ctx;
if (PC == 5) {
puts("\nReached address: 5, terminating the simulation...");
cpu->status = 1;
}
}
int main(int argc, char *argv[])
{
/*
* Instantiate the CPU, activate the debug mode, set the intercept
* function and run the virtual CPU until the termination criteria
* set by the intercept function, if any, are met.
*/
z80 *cpu = z80_new();
cpu->debug = 1;
z80_set_intercept(cpu, cpu, intercept);
z80_run(cpu);
z80_destroy(cpu);
}