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/>.
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
31 * The Gameboy is allegedly a Z80 with the following mods:
33 * - No index registers
34 * - No alternate registers
36 * - No I/O instructions (all I/O is memory mapped)
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
103 * Indirect Addressing delimeters
128 * Conditional definitions
141 #define S_R16X 34 /* AF */
181 #define S_LDHL 90 /* LDHL SP,offset */
185 #define S_TILE 93 /* .TILE pseudo-op */
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 */
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
);
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);
224 extern VOID
machine();