blob: b99763ffbbb43074e256aeaee8cf39961866de2a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/* pdkadr.c */
/*
* Copyright (C) 1998-2009 Alan R. Baldwin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Alan R. Baldwin
* 721 Berkeley St.
* Kent, Ohio 44240
*
* This Assember Ported by
* John L. Hartman (JLH)
* jhartman at compuserve dot com
* noice at noicedebugger dot com
*
*/
#include "asxxxx.h"
#include "pdk.h"
/* Classify argument as to address mode */
int
addr(struct expr *esp)
{
int c = getnb(), c1;
switch (c) {
case '#':
/* Immediate mode */
expr(esp, 0);
esp->e_mode = S_K;
break;
case 'a':
/* Accumulator */
esp->e_mode = S_A;
break;
case 's':
if ((c1 = getnb()) == 'p') {
/* Stack (SP) */
esp->e_mode = S_IO;
esp->e_addr = 2;
break;
}
unget(c1);
goto fallback;
case 'f':
/* ACC flag */
esp->e_mode = S_IO;
esp->e_addr = 0;
break;
default:
fallback:
unget(c);
/* Memory address */
expr(esp, 0);
esp->e_mode = S_M;
/* If there is no area information, assume that we have in
fact parsed an IO register variable - since any other constant
would have been prefixed by a '#'. */
if (!esp->e_flag && !esp->e_base.e_ap)
esp->e_mode = S_IO;
}
return (esp->e_mode);
}
int
pdkbit(struct expr *esp)
{
int c = getnb(), c1;
switch (c) {
case '#':
/* Bit number */
expr(esp, 0);
esp->e_mode = S_K;
break;
case 'a':
if ((c1 = getnb()) == 'c') {
/* AC bit of ACC flag */
esp->e_mode = S_K;
esp->e_addr = 2;
break;
}
unget(c1);
goto fallback;
case 'o':
if ((c1 = getnb()) == 'v') {
/* OV bit of ACC flag */
esp->e_mode = S_K;
esp->e_addr = 3;
break;
}
unget(c1);
goto fallback;
case 'c':
/* C bit of ACC flag */
esp->e_mode = S_K;
esp->e_addr = 1;
break;
case 'z':
/* Z bit of ACC flag */
esp->e_mode = S_K;
esp->e_addr = 0;
break;
case 'f':
/* ACC status flag */
esp->e_mode = S_IO;
esp->e_addr = -2;
break;
default:
fallback:
unget(c);
/* Error */
esp->e_mode = 0;
esp->e_addr = 0;
}
return (esp->e_mode);
}
|