OSDN Git Service

[VM][FMTOWNS] Add FONT ROMS, MSDOS ROM, SYSTEM ROM and SERIAL ROM.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mc6809_consts.h
1 /*
2         Skelton for retropc emulator
3
4         Origin : MAME 0.142
5         Author : Takeda.Toshiya
6         Date   : 2011.05.06-
7
8         [ MC6809 ]
9 */
10
11 // Fixed IRQ/FIRQ by Mr.Sasaji at 2011.06.17
12
13 #ifndef _MC6809_CONSTS_H
14 #define _MC6809_CONSTS_H
15
16 #define MC6809_IRQ_BIT  1       /* IRQ line number  */
17 #define MC6809_FIRQ_BIT 2       /* FIRQ line number */
18 #define MC6809_NMI_BIT  4       /* NMI line number  */
19 #define MC6809_HALT_BIT 8       /* HALT line number  */
20
21 /* flag bits in the cc register */
22 #define MC6809_CWAI      0x0010 /* set when CWAI is waiting for an interrupt */
23 #define MC6809_SYNC      0x0020 /* set when SYNC is waiting for an interrupt */
24 #define MC6809_CWAI_IN   0x0040 /* set when CWAI is waiting for an interrupt */
25 #define MC6809_CWAI_OUT  0x0080 /* set when CWAI is waiting for an interrupt */
26 #define MC6809_SYNC_IN   0x0100 /* set when SYNC is waiting for an interrupt */
27 #define MC6809_SYNC_OUT  0x0200 /* set when SYNC is waiting for an interrupt */
28 #define MC6809_LDS       0x0400 /* set when LDS occured at least once */
29 #define MC6809_NMI_LC    0x1000 /* NMI割り込み信号3サイクル未満 */
30 #define MC6809_FIRQ_LC   0x2000 /* FIRQ割り込み信号3サイクル未満 */
31 #define MC6809_IRQ_LC    0x4000 /* IRQ割り込み信号3サイクル未満 */
32 #define MC6809_INSN_HALT 0x8000 /* IRQ割り込み信号3サイクル未満 */
33
34 #define CC_C    0x01            /* Carry */
35 #define CC_V    0x02            /* Overflow */
36 #define CC_Z    0x04            /* Zero */
37 #define CC_N    0x08            /* Negative */
38 #define CC_II   0x10            /* Inhibit IRQ */
39 #define CC_H    0x20            /* Half (auxiliary) carry */
40 #define CC_IF   0x40            /* Inhibit FIRQ */
41 #define CC_E    0x80            /* entire state pushed */
42
43 // Macros move from mc6809.cpp .
44 #define pPPC    ppc
45 #define pPC     pc
46 #define pU      u
47 #define pS      s
48 #define pX      x
49 #define pY      y
50 #define pD      acc
51
52 #define PPC     ppc.w.l
53 #define PC      pc.w.l
54 #define PCD     pc.d
55 #define U       u.w.l
56 #define UD      u.d
57 #define S       s.w.l
58 #define SD      s.d
59 #define X       x.w.l
60 #define XD      x.d
61 #define Y       y.w.l
62 #define YD      y.d
63 #define D       acc.w.l
64 #define A       acc.b.h
65 #define B       acc.b.l
66 #define DP      dp.b.h
67 #define DPD     dp.d
68 #define CC      cc
69
70 #define EA      ea.w.l
71 #define EAD     ea.d
72 #define EAP     ea
73
74 /****************************************************************************/
75 /* memory                                                                   */
76 /****************************************************************************/
77
78
79
80 #define RM(Addr)        d_mem->read_data8(Addr & 0xffff)
81 #define WM(Addr,Value)  d_mem->write_data8(Addr & 0xffff, Value)
82
83 #define ROP(Addr)       d_mem->read_data8(Addr & 0xffff)
84 #define ROP_ARG(Addr)   d_mem->read_data8(Addr & 0xffff)
85
86 /* macros to access memory */
87 #define IMMBYTE(b)      b = ROP_ARG(PCD); PC++
88 #define IMMWORD(w)      w = RM16_PAIR(PCD); PC = (PC + 2) & 0xffff;
89
90 #define PUSHBYTE(b)     S = (S - 1) & 0xffff; WM(SD,b) ; 
91 #define PUSHWORD(w)     S = (S - 2) & 0xffff; WM16(SD, &w);
92 #define PULLBYTE(b)     b = RM(SD); S = (S + 1) & 0xffff;
93 #define PULLWORD(w)     w = RM16_PAIR(SD); SD = (SD + 2) & 0xffff;
94
95
96 #define PSHUBYTE(b)     U = (U - 1) & 0xffff; WM(UD, b);
97 #define PSHUWORD(w)     U = (U - 2) & 0xffff; WM16(UD, &w);
98 #define PULUBYTE(b)     b = RM(UD); U = (U + 1) & 0xffff
99 #define PULUWORD(w)     w = RM16_PAIR(UD); UD = (UD + 2) & 0xffff;
100
101
102 /* macros to set status flags */
103 #define SEC             CC |= CC_C
104 #define CLC             CC &= ~CC_C
105 #define SEZ             CC |= CC_Z
106 #define CLZ             CC &= ~CC_Z
107 #define SEN             CC |= CC_N
108 #define CLN             CC &= ~CC_N
109 #define SEV             CC |= CC_V
110 #define CLV             CC &= ~CC_V
111 #define SEH             CC |= CC_H
112 #define CLH             CC &= ~CC_H
113
114 #define CLR_HNZVC       CC &= ~(CC_H | CC_N | CC_Z | CC_V | CC_C)
115 #define CLR_NZV         CC &= ~(CC_N | CC_Z | CC_V)
116 #define CLR_NZ          CC &= ~(CC_N | CC_Z)
117 #define CLR_HNZC        CC &= ~(CC_H | CC_N | CC_Z | CC_C)
118 #define CLR_NZVC        CC &= ~(CC_N | CC_Z | CC_V | CC_C)
119 #define CLR_Z           CC &= ~(CC_Z)
120 #define CLR_NZC         CC &= ~(CC_N | CC_Z | CC_C)
121 #define CLR_ZC          CC &= ~(CC_Z | CC_C)
122
123 /* macros for CC -- CC bits affected should be reset before calling */
124 #define SET_Z8(a)               if((a & 0x00ff) == 0) SEZ
125 #define SET_Z16(a)              if((a & 0x00ffff) == 0) SEZ
126 //#define SET_N8(a)             CC |= ((a & 0x80) >> 4)
127 //#define SET_N16(a)            CC |= ((a & 0x8000) >> 12)
128 #define SET_H(a,b,r)            if(((a ^ b ^ r) & 0x10) != 0) SEH
129 #define SET_N8(a)       if(a & 0x80) SEN
130 #define SET_N16(a)       if(a & 0x8000) SEN
131 //#define SET_H(a,b,r)  if((a^b^r)&0x10) SEH
132
133 #define SET_C8(a)       if((a&0x0100) != 0) SEC
134 #define SET_C16(a)      if((a&0x010000) != 0) SEC
135 #define SET_V8(a,b,r)   if(((a^b^r^(r>>1))&0x80) != 0) SEV
136 #define SET_V16(a,b,r)  if(((a^b^r^(r>>1))&0x8000) != 0) SEV
137
138 #define SET_FLAGS8I(a)          {CC |= flags8i[a & 0xff];}
139 #define SET_FLAGS8D(a)          {CC |= flags8d[a & 0xff];}
140
141 /* combos */
142 #define SET_NZ8(a)              {SET_N8(a); SET_Z8(a);}
143 #define SET_NZ16(a)             {SET_N16(a); SET_Z16(a);}
144 #define SET_FLAGS8(a,b,r)       {SET_N8(r); SET_Z8(r); SET_V8(a, b, r); SET_C8(r);}
145 #define SET_FLAGS16(a,b,r)      {SET_N16(r); SET_Z16(r); SET_V16(a, b, r); SET_C16(r);}
146 #define SET_HNZVC8(a,b,r)       {SET_H(a,b,r);SET_N8(r);SET_Z8(r);SET_V8(a,b,r);SET_C8(r);}
147 #define SET_HNZVC16(a,b,r)      {SET_H(a,b,r);SET_N16(r);SET_Z16(r);SET_V16(a,b,r);SET_C16(r);}
148
149
150 //#define NXORV         ((CC & CC_N) ^ ((CC & CC_V) << 2))
151 #define NXORV                   (((CC&CC_N)^((CC&CC_V)<<2)) !=0)
152 /* for treating an unsigned byte as a signed word */
153 #define SIGNED(b)       ((uint16_t)((b & 0x80) ? (b | 0xff00) : (b & 0x00ff)))
154
155    
156    
157 /* macros for addressing modes (postbytes have their own code) */
158 #define DIRECT          EAD = DPD; IMMBYTE(ea.b.l)
159
160 #define IMM8            EAD = PCD; PC++
161 #define IMM16           EAD = PCD; PC += 2
162 #define EXTENDED        IMMWORD(EAP)
163
164 /* macros for convenience */
165 #define DIRBYTE(b)      {DIRECT;   b   = RM(EAD);  }
166 #define DIRWORD(w)      {DIRECT;   w = RM16_PAIR(EAD);}
167 #define EXTBYTE(b)      {EXTENDED; b   = RM(EAD);  }
168 #define EXTWORD(w)      {EXTENDED; w = RM16_PAIR(EAD);}
169
170       
171 #endif //#ifndef _MC6809_CONSTS_H