00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "cawf.h"
00032
00033
00034
00035
00036
00037
00038
00039 unsigned char *
00040 Asmcode(s, c)
00041 unsigned char **s;
00042 unsigned char *c;
00043 {
00044 unsigned char *s1;
00045
00046 s1 = *s + 1;
00047 c[0] = c[1] = c[2] = '\0';
00048 if ((c[0] = *s1) == '(') {
00049 s1++;
00050 if ((c[0] = *s1) != '\0') {
00051 s1++;
00052 c[1] = *s1;
00053 }
00054 }
00055 return(s1);
00056 }
00057
00058
00059
00060
00061
00062
00063 void
00064 Delnum(nx)
00065 int nx;
00066 {
00067 unsigned char buf[MAXLINE];
00068
00069 if (nx >= Nnr) {
00070 (void) sprintf((char *)buf, " bad Delnum(%d) index", nx);
00071 Error(FATAL, LINE, (char *)buf, NULL);
00072 }
00073 while (nx < (Nnr - 1)) {
00074 Numb[nx] = Numb[nx + 1];
00075 nx++;
00076 }
00077 Nnr--;
00078 }
00079
00080
00081
00082
00083
00084
00085 Findnum(n, v, e)
00086 unsigned char *n;
00087 int v;
00088 int e;
00089
00090 {
00091 int cmp, low, hi, mid;
00092 unsigned char c[3];
00093
00094 c[0] = n[0];
00095 c[1] = (n[1] == ' ' || n[1] == '\t') ? '\0' : n[1];
00096 c[2] = '\0';
00097 low = mid = 0;
00098 hi = Nnr - 1;
00099 while (low <= hi) {
00100 mid = (low + hi) / 2;
00101 if ((cmp = strncmp((char *)c, (char *)Numb[mid].nm, 2)) < 0)
00102 hi = mid - 1;
00103 else if (cmp > 0)
00104 low = mid + 1;
00105 else {
00106 if (e)
00107 Numb[mid].val = v;
00108 return(mid);
00109 }
00110 }
00111 if ( ! e)
00112 return(-1);
00113 if (Nnr >= MAXNR)
00114 Error(FATAL, LINE, " out of number registers at ", (char *)c);
00115 if (Nnr) {
00116 if (cmp > 0)
00117 mid++;
00118 for (hi = Nnr - 1; hi >= mid; hi--)
00119 Numb[hi+1] = Numb[hi];
00120 }
00121 Nnr++;
00122 Numb[mid].nm[0] = c[0];
00123 Numb[mid].nm[1] = c[1];
00124 Numb[mid].val = v;
00125 return(mid);
00126 }
00127
00128
00129
00130
00131
00132
00133 Findparms(n)
00134 unsigned char *n;
00135 {
00136 unsigned char c[3];
00137 int i;
00138
00139 c[0] = n[0];
00140 c[1] = (n[1] == ' ' || n[1] == '\t') ? '\0' : n[1];
00141 c[2] = '\0';
00142 for (i = 0; Parms[i].nm[0]; i++) {
00143 if (c[0] == Parms[i].nm[0] && c[1] == Parms[i].nm[1])
00144 return(i);
00145 }
00146 return(-1);
00147 }
00148
00149
00150
00151
00152
00153
00154 Findscale(n, v, e)
00155 int n;
00156 double v;
00157 int e;
00158
00159 {
00160 int i;
00161 double *pval;
00162
00163 for (i = 0; Scale[i].nm; i++) {
00164 if ((unsigned char )n == Scale[i].nm)
00165 break;
00166 }
00167 if (Scale[i].nm) {
00168 if (e) {
00169 pval = &Scale[i].val;
00170 *pval = v;
00171 }
00172 return(i);
00173 }
00174 return(-1);
00175 }