1 /* 2 * Module d'�mulation des micro-circuits Motorola MC68xx: 3 * - microprocesseur MC6809E 4 * - PIA MC6846 5 * - PIA MC6821 6 * 7 * Copyright (C) 1996 Sylvain Huet, 1999 Eric Botcazou, 2011 Gilles F�tis 8 * 2012 Fran�ois Mouret, 2012 Samuel Devulder. 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 */ 24 25 /* 26 * Module : mc6809.h 27 * Version : 2.7 28 * Cr�� par : Sylvain Huet 1996 29 * Modifi� par: Eric Botcazou 30/11/2000 30 * Gille F�tis 27/07/2011 31 * Fran�ois Mouret 07/02/2012 13/04/2014 32 * 33 * Emulateur du microprocesseur Motorola MC6809E. 34 * 35 * version 1.0: �mulation fonctionnelle 36 * version 2.0: horloge interne, interface 37 * version 2.1: interruption du timer 38 * version 2.2: nouvelles valeurs de retour des fonctions d'�x�cution 39 * version 2.3: encapsulation compl�te du module 40 * version 2.4: ajout d'un masque d'�criture des registres 41 * version 2.5: ajout d'une fonction trace (mode DEBUG) 42 * version 2.6: nouvelles commandes externes (RESET, NMI, FIRQ) 43 * correction mineure du mode index� 5-bit 44 * Fetch devient FetchInstr et utilise des unsigned char 45 * suppression d'un inline inutile 46 * version 2.7: nouvelle interface de manipulation de l'�tat du MC6809E 47 * 2.7.1: pr�-incr�ment de cpu_clock pour puls et pulu. 48 * 2.7.2: am�nagement pour le debugger. 49 * version 2.8: fusion des tables *code[], taille[], adr[], 50 * cpu_cycles[]. 51 * ajout des instructions non standard 52 * gestion des successions de codes Page2 ($10) et Page3 53 * ($11) 54 */ 55 56 57 #ifndef MC6809_H 58 #define MC6809_H 59 60 #ifdef DEBUG 61 #ifndef SCAN_DEPEND 62 #include <stdio.h> 63 #endif 64 65 extern FILE *mc6809_ftrace; 66 #endif 67 68 typedef unsigned long long int mc6809_clock_t; /* entier 64-bit */ 69 70 #define MC6809_TIMER_DISABLED (mc6809_clock_t) -1 71 72 #define MC6809_REGS_CC_FLAG (1<<0) 73 #define MC6809_REGS_DP_FLAG (1<<1) 74 #define MC6809_REGS_AR_FLAG (1<<2) 75 #define MC6809_REGS_BR_FLAG (1<<3) 76 #define MC6809_REGS_XR_FLAG (1<<4) 77 #define MC6809_REGS_YR_FLAG (1<<5) 78 #define MC6809_REGS_UR_FLAG (1<<6) 79 #define MC6809_REGS_SR_FLAG (1<<7) 80 #define MC6809_REGS_PC_FLAG (1<<8) 81 #define MC6809_REGS_CPUCLOCK_FLAG (1<<9) 82 #define MC6809_REGS_CPUTIMER_FLAG (1<<10) 83 #define MC6809_REGS_MAX_FLAG 11 84 85 #define MC6809_REGS_ALL_FLAG MC6809_REGS_CC_FLAG | \ 86 MC6809_REGS_DP_FLAG | \ 87 MC6809_REGS_AR_FLAG | \ 88 MC6809_REGS_BR_FLAG | \ 89 MC6809_REGS_XR_FLAG | \ 90 MC6809_REGS_YR_FLAG | \ 91 MC6809_REGS_UR_FLAG | \ 92 MC6809_REGS_SR_FLAG | \ 93 MC6809_REGS_PC_FLAG | \ 94 MC6809_REGS_CPUCLOCK_FLAG 95 96 97 struct CODES_6809_SPEC { 98 char name[6]; 99 void (*prog)(void); 100 int taille; 101 int adr; 102 int cpu_cycles; 103 }; 104 105 struct MC6809_REGS 106 { 107 int cc; 108 int dp; 109 int ar; 110 int br; 111 int xr; 112 int yr; 113 int ur; 114 int sr; 115 int pc; 116 mc6809_clock_t cpu_clock; 117 mc6809_clock_t cpu_timer; 118 }; 119 120 121 struct MC6809_INTERFACE 122 { 123 void (*FetchInstr)(int, unsigned char []); 124 int (*LoadByte)(int); 125 int (*LoadWord)(int); 126 void (*StoreByte)(int, int); 127 void (*StoreWord)(int, int); 128 int (*TrapCallback)(struct MC6809_REGS *); 129 }; 130 extern struct MC6809_INTERFACE mc6809_interface; 131 132 133 extern void mc6809_Init(); 134 extern void mc6809_GetRegs(struct MC6809_REGS *); 135 extern void mc6809_SetRegs(const struct MC6809_REGS *, int); 136 extern void mc6809_SetTimer(mc6809_clock_t, void (*)(void *), void *); 137 extern void mc6809_Reset(void); 138 extern void mc6809_FlushExec(void); 139 extern int mc6809_StepExec(void); 140 extern int mc6809_TimeExec(mc6809_clock_t); 141 extern mc6809_clock_t mc6809_clock(void); 142 extern int mc6809_irq; 143 144 #endif 145