struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / sdas / asgb / gb.h
blobf51e92764fc4e3048a235becd74a54afe0bdd108
1 /* gb.h */
3 /*
4 * Copyright (C) 1989-2021 Alan R. Baldwin
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Alan R. Baldwin
21 * 721 Berkeley St.
22 * Kent, Ohio 44240
25 /* Gameboy mods by Roger Ivie (ivie at cc dot usu dot edu)
27 * The Gameboy mods are based on
28 * http://www.komkon.org/fms/GameBoy/Tech/Software.html
29 * by Marat Fayzullin
31 * The Gameboy is allegedly a Z80 with the following mods:
33 * - No index registers
34 * - No alternate registers
35 * - No I and R
36 * - No I/O instructions (all I/O is memory mapped)
37 * - No parity flag
38 * - No minus flag
39 * - No instructions with ED prefix (RETI is moved)
40 * - HALT is always interruptible, even if interrupts have been disabled.
41 * - The following instructions are different:
42 * - No ADC or SBC of r16s.
44 * ----------------------------------------------------------------------------
45 * Code Z80 operation GameBoy operation
46 * ----------------------------------------------------------------------------
47 * 08 xx xx EX AF,AF' LD (word),SP Save SP at given address
48 * 10 xx DJNZ offset STOP Meaning unknown
49 * 22 LD (word),HL LD (HLI),A Save A at (HL) and increment HL
50 * 2A LD HL,(word) LD A,(HLI) Load A from (HL) and increment HL
51 * 32 LD (word),A LD (HLD),A Save A at (HL) and decrement HL
52 * 3A LD A,(word) LD A,(HLD) Load A from (HL) and decrement HL
53 * D3 OUTA (byte) No operation
54 * D9 EXX RETI Enable interrupts and return
55 * DB INA (byte) No operation
56 * DD Prefix DD No operation
57 * E0 xx RET PO LD (byte),A Save A at (FF00+byte)
58 * E2 JP PO,word LD (C),A Save A at (FF00+C)
59 * E3 EX HL,(SP) No operation
60 * E4 CALL PO,word No operation
61 * E8 xx RET PE ADD SP,offset Add signed offset to SP
62 * EA xx xx JP PE,word LD (word),A Save A at given address
63 * EB EX DE,HL No operation
64 * EC CALL PE,word No operation
65 * F0 xx RET P LD A,(byte) Load A from (FF00+byte)
66 * F2 JP P,word No operation
67 * F4 CALL P,word No operation
68 * F8 xx RET M LDHL SP,offset Load HL with SP + signed offset
69 * FA xx xx JP M,word LD A,(word) Load A from given address
70 * FC CALL M,word No operation
71 * FD Prefix FD No operation
72 * ----------------------------------------------------------------------------
76 * Extensions: P. Felber
79 /*)BUILD
80 $(PROGRAM) = ASGB
81 $(INCLUDE) = {
82 ASXXXX.H
83 GB.H
85 $(FILES) = {
86 GBMCH.C
87 GBADR.C
88 GBPST.C
89 ASMAIN.C
90 ASDBG.C
91 ASLEX.C
92 ASSYM.C
93 ASSUBR.C
94 ASEXPR.C
95 ASDATA.C
96 ASLIST.C
97 ASOUT.C
99 $(STACK) = 3000
103 * Indirect Addressing delimeters
105 #define LFIND '('
106 #define RTIND ')'
109 * Registers
111 #define B 0
112 #define C 1
113 #define D 2
114 #define E 3
115 #define H 4
116 #define L 5
117 #define A 7
119 #define BC 0
120 #define DE 1
121 #define HL 2
122 #define SP 3
123 #define AF 4
124 #define HLD 5
125 #define HLI 6
128 * Conditional definitions
130 #define NZ 0
131 #define Z 1
132 #define NC 2
133 #define CS 3
136 * Symbol types
138 #define S_IMMED 30
139 #define S_R8 31
140 #define S_R16 33
141 #define S_R16X 34 /* AF */
142 #define S_CND 35
143 #define S_FLAG 36
146 * Indexing modes
148 #define S_INDB 40
149 #define S_IDC 41
150 #define S_INDR 50
151 #define S_IDBC 50
152 #define S_IDDE 51
153 #define S_IDHL 52
154 #define S_IDSP 53
155 #define S_IDHLD 55
156 #define S_IDHLI 56
157 #define S_INDM 57
160 * Instruction types
162 #define S_LD 60
163 #define S_CALL 61
164 #define S_JP 62
165 #define S_JR 63
166 #define S_RET 64
167 #define S_BIT 65
168 #define S_INC 66
169 #define S_DEC 67
170 #define S_ADD 68
171 #define S_ADC 69
172 #define S_AND 70
173 #define S_PUSH 72
175 #define S_RL 76
176 #define S_RST 77
177 #define S_IM 78
178 #define S_INH1 79
179 #define S_SUB 80
180 #define S_SBC 81
181 #define S_LDHL 90 /* LDHL SP,offset */
182 #define S_LDA 91
183 #define S_STOP 83
184 #define S_LDH 84
185 #define S_TILE 93 /* .TILE pseudo-op */
187 struct adsym
189 char a_str[4]; /* addressing string */
190 int a_val; /* addressing mode value */
193 extern struct adsym R8[];
194 extern struct adsym R16[];
195 extern struct adsym R16X[];
196 extern struct adsym CND[];
198 /* machine dependent functions */
200 #ifdef OTHERSYSTEM
202 /* gbadr.c */
203 extern int addr(struct expr *esp);
204 extern int admode(struct adsym *sp);
205 extern int any(int c, char *str);
206 extern int srch(char *str);
208 /* gbmch.c */
209 extern int genop(int pop, int op, struct expr *esp, int f);
210 extern VOID machine(struct mne *mp);
211 extern int mchpcr(struct expr *esp);
212 extern VOID minit(void);
214 #else
216 /* gbadr.c */
217 extern int addr();
218 extern int admode();
219 extern int any();
220 extern int srch();
222 /* gbmch.c */
223 extern int genop();
224 extern VOID machine();
225 extern int mchpcr();
226 extern VOID minit();
228 #endif