Mercurial > repos > simple16
view src/cpu.h @ 11:04d8efe7a1f0
Initial stab at video output and background color rendering. Fixed address decoding in address port write handler.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 27 Mar 2016 17:36:02 -0700 |
parents | 5176efdda5ae |
children | fb14515266f4 |
line wrap: on
line source
#ifndef CPU_H_ #define CPU_H_ typedef struct cpu cpu; typedef void (*port_write_fun) (cpu *context, uint8_t port, uint16_t value); typedef uint16_t (*port_read_fun) (cpu *context, uint8_t port); typedef struct { port_write_fun write; port_read_fun read; } port_handler; #define MEM_READ 1 #define MEM_WRITE 2 typedef struct { uint8_t *base; uint16_t start; uint16_t end; uint8_t flags; } memory_region; struct cpu { void *system; uint32_t cycles; uint32_t clock_inc; uint32_t num_mem_regions; uint16_t regs[16]; uint16_t exception; uint16_t exception_pc; uint16_t exception_sr; uint16_t exception_ur; uint16_t vector_base; uint16_t prefetch; uint8_t state; port_handler port_handlers[16]; memory_region mem_regions[]; }; cpu* alloc_cpu(uint32_t clock_divider, uint32_t num_regions, memory_region *regions); void run_cpu(cpu *context, uint32_t target_cycle); extern char * mnemonics[]; extern char * mnemonics_single_src[]; extern char * mnemonics_single_reg[]; enum { LDIM, LDIMH, LD8, LD16, STR8, STR16, ADD, ADC, AND, OR, XOR, LSL, LSR, ASR, BCC, SINGLE_SOURCE }; enum { MOVE, NEG, NOT, CMP, CALL, SWAP, IN, OUT, INI, OUTI, ADDI, ANDI, ORI, LSI, CMPI, SINGLE_REG }; enum { RETI, TRAP, TRAPI, GETEPC, SETEPC, GETESR, SETESR, GETEUR, SETEUR, GETENUM, SETENUM }; enum { COND_ALWAYS, COND_NEVER, COND_ZERO, COND_NZERO, COND_NEG, COND_POS, COND_CARRY, COND_NCARRY, COND_GREATER, COND_LEQ }; #define REG_PC 14 #define REG_SR 15 #endif //CPU_H_