cpu8bit2.h

来自「极小的CPU的VHDL源代码」· C头文件 代码 · 共 81 行

H
81
字号
/*

   4 Bit CPU Emulation, hacker version

   07.07.2000 Tim B鰏cke

    CPU model static variables

  */

#ifndef __CPU8Bit2_h
#define __CPU8Bit2_h

#include "hexfileio.h"

typedef struct
{
	/* CPU State */
/*
	u32 PC;
	u8 Regs[32];
	u8 Akku;
	u8 CFlag;
	u8 ZFlag;
	u8 *Rom;
*/
	u8 Akku;
	u32 PC;		// Lets keep it flexible..
	u8  CFlag;
	u8 *Ram;
	/* Statistics */

	u32	NumInstructions;
	u32 NumCycles;

} Cpu8Bit2State;

/* new CPU */

Cpu8Bit2State* CPU_New(void);	

/* load program data into program memory rom/ram */

void CPU_LoadProgram(Cpu8Bit2State *state,HexFile *file);

/* Reset CPU */

void CPU_Reset(Cpu8Bit2State *state);

/* Step */

void CPU_Step(Cpu8Bit2State *state);

/* free CPU struct */

void CPU_Free(Cpu8Bit2State *state);	

/* Disassemble.. returns number of words in instruction */

u32	CPU_Disassemble(Cpu8Bit2State *state,u32 adress,char *string);

/* Return next instruction word adress*/

u32	CPU_NextAdress(Cpu8Bit2State *state,u32 adress);
u32	CPU_PreviousAdress(Cpu8Bit2State *state,u32 adress);

/* returns branch target, if instruction is branch. Otherwhise 0xffffffff */

u32	CPU_BranchTarget(Cpu8Bit2State *state,u32 adress);

/* Returns value depending on branch execution */

u32 CPU_EvaluateBranch(Cpu8Bit2State *state,u32 adress);

#define CPUC_NOBRANCH 0
#define CPUC_BRANCHTAKEN 1
#define CPUC_BRANCHNOTTAKEN 2
#define CPUC_BRANCHALWAYS 3

#define RamSize 64
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?