This commit is contained in:
d0p1 🏳️‍⚧️ 2024-02-29 13:01:58 +01:00
parent d53f1cbfe0
commit 9b918d43ce
5 changed files with 62 additions and 0 deletions

16
vm/bus.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef VM_BUS_H
# define VM_BUS_H 1
# include <stddef.h>
# include <stdint.h>
typedef int (*BusRead)(uint32_t addr, void *data, size_t sz);
typedef int (*BusWrite)(uint32_t addr, const void *data, size_t sz);
typedef struct
{
BusRead read;
BusWrite write;
} Bus;
#endif /* !VM_BUS_H */

7
vm/cpu.c Normal file
View file

@ -0,0 +1,7 @@
#include "cpu.h"
void
cpu_execute(Cpu *cpu)
{
uint8_t opcode;
}

16
vm/cpu.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef VM_CPU_H
# define VM_CPU_H 1
# include <stdint.h>
typedef struct
{
uint32_t PC;
uint32_t A;
uint32_t X;
uint32_t Y;
uint8_t SR;
uint32_t SP;
} Cpu;
#endif /* !VM_CPU_H */

View file

@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
#include "config.h"
static const char *prg_name;
@ -9,6 +10,12 @@ usage(void)
printf("Usage: %s [-hV] [-b bios]\n");
}
void
version(void)
{
printf("%S v%s\n", PACKAGE_NAME, PACKAGE_VERSION);
}
int
main(int argc, char **argv)
{

16
vm/vm.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef VM_VM_H
# define VM_VM_H 1
# include "cpu.h"
# include "bus.h"
# define VM_MAX_CPU 8
typedef struct
{
int cpu_count;
Cpu cpus[VM_MAX_CPU];
Bus bus;
} Vm;
#endif /* !VM_VM_H */