9 #include "symbol_tbl.h"
12 static char *read_label(char *line
, int lcount
, int line_nr
, int *pass1_error
)
16 char *p
, label
[LABEL_LEN
];
18 p
= strchr(line
, ':');
23 if (len
>= (sizeof(label
) - 1)) {
24 error(line_nr
, "label is too big");
30 if (*pass1_error
== 0) {
31 memset(label
, 0, sizeof(label
));
32 strncpy(label
, line
, sizeof(label
) - 1);
33 err
= symbol_tbl_insert(label
, lcount
, line_nr
);
38 return skip_spaces(p
, strlen(p
));
43 * Perform assembler first pass
45 * o Populates the symbol table
46 * o Remove prefixed spaces
49 * asmfp: asm FILE pointer (input)
50 * interfp: intermediate FILE pointer (output)
53 int das_pass1(FILE *asmfp
, FILE *interfp
, int debug
)
55 char line
[DEF_LINE_LEN
], *p
;
56 int line_nr
, lcount
, err
, ret
;
60 for (line_nr
= 1;; line_nr
++) {
61 ret
= file_read_line(asmfp
, line
, DEF_LINE_LEN
);
65 p
= skip_spaces(line
, strlen(line
));
69 p
= read_label(p
, lcount
, line_nr
, &err
);
73 ret
= fprintf(interfp
, "%s", p
);
75 fatal("pass1 could not write to file: %s",