4 * Copyright (C) 1998-2009 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/>.
24 * This Assember Ported by
25 * John L. Hartman (JLH)
26 * jhartman at compuserve dot com
27 * noice at noicedebugger dot com
35 struct adsym reg51
[] = { /* R0 thru R7 registers */
52 /* Classify argument as to address mode */
54 addr(struct expr
*esp
)
59 if ((c
= getnb()) == '#') {
62 esp
->e_mode
= S_IMMED
;
65 /* choices are @R0, @R1, @DPTR, @A+PC, @A+DPTR */
76 esp
->e_mode
= S_AT_DP
;
83 esp
->e_mode
= S_AT_APC
;
85 } else if (rd
== DPTR
) {
86 esp
->e_mode
= S_AT_ADP
;
89 xerr('a', "@A+DPTR and A,@A+PC are the allowed modes.");
92 xerr('a', "Invalid Addressing Mode.");
97 esp
->e_base
.e_ap
= NULL
;
100 if ((c
= getnb()) == '/') {
101 /* Force inverted bit */
103 esp
->e_mode
= S_NOT_BIT
;
106 /* Force direct page */
110 if (esp
->e_addr
& ~0xFF)
111 xerr('d', "A Direct Page addressing error.");
114 /* Force inverted bit */
116 esp
->e_mode
= S_NOT_BIT
;
121 /* try for register: A, AB, R0-R7, DPTR, PC, Cy */
122 if ((esp
->e_addr
= admode(reg51
)) != -1) {
123 switch (esp
->e_addr
) {
131 esp
->e_mode
= S_DPTR
;
144 /* Must be an expression */
148 && (esp
->e_base
.e_ap
==NULL
)
149 && !(esp
->e_addr
& ~0xFF)) {
156 return (esp
->e_mode
);
160 * Enter admode() to search a specific addressing mode table
161 * for a match. Return the addressing value on a match or
165 admode(struct adsym
*sp
)
172 while ( *(ptr
= &sp
[i
].a_str
[0]) ) {
182 * srch --- does string match ?
190 while (*ptr
&& *str
) {
191 if(ccase
[*ptr
& 0x007F] != ccase
[*str
& 0x007F])
196 if (ccase
[*ptr
& 0x007F] == ccase
[*str
& 0x007F]) {
202 if (any(*ptr
," \t\n,];")) {
210 * any --- does str contain c?
213 any(int c
, char *str
)
222 * Read a register name. Return register value, -1 if no register found
231 if ((mp
= mlookup(id
))==NULL
) {
235 switch (mp
->m_type
) {
241 return ((int) mp
->m_valu
);