comparison a09.c @ 8:96a067cf4c4f

level2 rom done
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 05 Jul 2018 12:07:06 +0900
parents a6db579d8c11
children ce7323f9b937
comparison
equal deleted inserted replaced
7:a6db579d8c11 8:96a067cf4c4f
179 179
180 int symcounter=0; 180 int symcounter=0;
181 int os9 = 0; // os9 flag 181 int os9 = 0; // os9 flag
182 int prevloc = 0; 182 int prevloc = 0;
183 183
184 /* Symbol categories. 184 /* expression categories...
185 0 Constant value (from equ). 185 ECORD all zeros is ordinary constant.
186 1 Variable value (from set) 186 ECADR bit 1 indicates address within module.
187 2 Address within program module (label). 187 ECEXT bit 2 indicates external address.
188 3 Variable containing address. 188 ECLBL bit 3 public label
189 4 Adress in other program module (extern) 189 ECABS bit 4 indicates this can't be relocated if it's an address.
190 5 Variable containing external address. 190 ECNEG bit 5 indicates address (if any) is negative.
191 6 Unresolved address. 191 */
192 7 Variable containing unresolved address. 192
193 8 Public label. 193
194 9 Macro definition. 194 /* Symbol categories. exprcat ( symcat & 0xe )
195 10 Public label (yet undefined). 195 0 SCC Constant value (from equ). ECORD
196 11 parameter name. 196 1 SCV Variable value (from set) ECORD
197 12 local label. 197 2 SCC__ADR Address within program module (label). ECADR
198 13 empty. 198 3 SCV__ADR Variable containing address. ECADR
199 4 SC_E_ADR Adress in other program module (extern) ECEXT
200 5 SCVE_ADR Variable containing external address. ECEXT
201 6 SCU _ADR Unresolved address. ECEXT+ECADR
202 7 SCV_UADR Variable containing unresolved address. ECEXT+ECADR
203 8 SC___LBL Public label. ECLBL
204 9 SCMACRO Macro definition. xxx
205 10 SCU__LBL Public label (yet undefined). ECADR+ECLBL
206 11 SCPARAM parameter name. ECADR+ECLBL
207 12 SCLOCAL local label. ECEXT+ECLBL
208 13 SCEMPTY empty. xxx
199 */ 209 */
200 210
201 struct symrecord symtable[NLABELS]; 211 struct symrecord symtable[NLABELS];
202 212
203 void processfile(char *name); 213 void processfile(char *name);
428 exprcat==4) 438 exprcat==4)
429 certain=0; 439 certain=0;
430 if(exprcat==8||exprcat==6||exprcat==10)exprcat=2; 440 if(exprcat==8||exprcat==6||exprcat==10)exprcat=2;
431 return p->value; 441 return p->value;
432 } 442 }
433
434 /* expression categories...
435 all zeros is ordinary constant.
436 bit 1 indicates address within module.
437 bit 2 indicates external address.
438 bit 4 indicates this can't be relocated if it's an address.
439 bit 5 indicates address (if any) is negative.
440 */
441
442 443
443 444
444 short scanfactor() 445 short scanfactor()
445 { 446 {
446 char c; 447 char c;
932 break; 933 break;
933 case 4: case 6: offs=(unsigned short)operand-loccounter-codeptr-2; 934 case 4: case 6: offs=(unsigned short)operand-loccounter-codeptr-2;
934 if(offs<-128||offs>=128||opsize==3||unknown||!certain) { 935 if(offs<-128||offs>=128||opsize==3||unknown||!certain) {
935 if((!unknown)&&opsize==2&&(offs<-128||offs>=128) ) 936 if((!unknown)&&opsize==2&&(offs<-128||offs>=128) )
936 error|=16; 937 error|=16;
937 offs--; 938 // offs--;
938 opsize=3; 939 // opsize=3;
939 postbyte++; 940 // postbyte++;
940 } 941 }
941 putbyte(postbyte); 942 putbyte(postbyte);
942 if (debug) fprintf(stderr,"DEBUG: doaddress: mode=%d, opsize=%d, error=%d, postbyte=%02X, operand=%04X offs=%d\n",mode,opsize,error,postbyte,operand,offs); 943 if (debug) fprintf(stderr,"DEBUG: doaddress: mode=%d, opsize=%d, error=%d, postbyte=%02X, operand=%04X offs=%d\n",mode,opsize,error,postbyte,operand,offs);
943 if(opsize==3)putword(offs); 944 if(opsize==3)putword(offs);
944 else putbyte(offs); 945 else putbyte(offs);