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 * jhartman at compuserve dot com
26 * noice at noicedebugger dot com
28 * Modified from i51pst.c
30 * w_mckinnon at conknet dot com
38 struct adsym reg51
[] = { /* R0 thru R7 registers */
55 /* Classify argument as to address mode */
57 addr(struct expr
*esp
)
62 if ((c
= getnb()) == '#') {
65 esp
->e_mode
= S_IMMED
;
68 /* choices are @R0, @R1, @DPTR, @A+PC, @A+DPTR */
79 esp
->e_mode
= S_AT_DP
;
86 esp
->e_mode
= S_AT_APC
;
88 } else if (rd
== DPTR
) {
89 esp
->e_mode
= S_AT_ADP
;
92 xerr('a', "@A+DPTR and A,@A+PC are the allowed modes.");
95 xerr('a', "Invalid Addressing Mode.");
100 esp
->e_base
.e_ap
= NULL
;
103 if ((c
= getnb()) == '/') {
104 /* Force inverted bit */
106 esp
->e_mode
= S_NOT_BIT
;
109 /* Force direct page */
113 if (esp
->e_addr
& ~0xFF)
114 xerr('d', "A Direct Page addressing error.");
117 /* Force inverted bit */
119 esp
->e_mode
= S_NOT_BIT
;
124 /* try for register: A, AB, R0-R7, DPTR, PC, Cy */
125 if ((esp
->e_addr
= admode(reg51
)) != -1) {
126 switch (esp
->e_addr
) {
134 esp
->e_mode
= S_DPTR
;
147 /* Must be an expression */
148 esp
->e_addr
= 0; /* Vasiliy Petrov */
151 && (esp
->e_base
.e_ap
==NULL
)
152 && !(esp
->e_addr
& ~0xFF)) {
159 return (esp
->e_mode
);
163 * Enter admode() to search a specific addressing mode table
164 * for a match. Return the addressing value on a match or
168 admode(struct adsym
*sp
)
175 while ( *(ptr
= &sp
[i
].a_str
[0]) ) {
185 * srch --- does string match ?
193 while (*ptr
&& *str
) {
194 if(ccase
[*ptr
& 0x007F] != ccase
[*str
& 0x007F])
199 if (ccase
[*ptr
& 0x007F] == ccase
[*str
& 0x007F]) {
205 if (any(*ptr
," \t\n,];")) {
213 * any --- does str contain c?
216 any(int c
, char *str
)
225 * Read a register name. Return register value, -1 if no register found
234 if ((mp
= mlookup(id
))==NULL
) {
238 switch (mp
->m_type
) {
244 return ((int) mp
->m_valu
);