/* * Pass 2: * - process one line of source * * Output: 1 line processed * 0 EOF */ int p2_line(void) { register char *p; register int op_count; register struct opc *op; if ((p = fgets(line, MAXLINE, srcfp)) == NULL) return(0); c_line++; s_line++; p = get_label(label, p); p = get_opcode(opcode, p); p = get_arg(operand, p); if (strcmp(opcode, ENDFILE) == 0) { lst_line(pc, 0); return(0); } if (*opcode) { op = search_op(opcode); op_count = (*op->op_fun)(op->op_c1, op->op_c2); if (gencode) { lst_line(pc, op_count); obj_writeb(op_count); pc += op_count; } else { sd_flag = 2; lst_line(0, 0); } } else { sd_flag = 2; lst_line(0, 0); } return(1); }
void lst_memory_map(MemBlock *m) { char buf[BUFSIZ]; char *e; int i, j, base, row_used; lst_line(""); lst_line(""); lst_line("MEMORY USAGE MAP ('X' = Used, '-' = Unused)"); lst_line(""); while(m) { assert(m->memory != NULL); base = (m->base << I_MEM_BITS); for(i = 0; i<MAX_I_MEM; i+=64) { row_used = 0; for(j = 0; j<64; j++) if( m->memory[i+j] ) row_used = 1; if(row_used) { e = buf; sprintf(e, "%04x :", (i + base)); e += strlen(e); for(j = 0; j<64; j++) { if ((j%16) == 0) { *e++ = ' '; } if ((i_memory_get(m, i+j) & MEM_USED_MASK)) { *e++ = 'X'; } else { *e++ = '-'; } } *e = '\0'; /* terminate the new string */ lst_line(buf); } } m = m->next; } lst_line(""); lst_line("All other memory blocks unused."); lst_line(""); sprintf(buf, "Program Memory Words Used: %i", i_memory_used(state.i_memory)); lst_line(buf); }
void lst_line(char *line) { if (state.lst.f) { if (state.lst.linesperpage != 0) { if ((state.lst.lineofpage++ % state.lst.linesperpage) == 0) { lst_throw(); lst_line("LOC OBJECT CODE LINE SOURCE TEXT"); lst_line(" VALUE"); lst_line(" "); } } fprintf(state.lst.f, "%s\n", line); state.lst.line_number++; cod_lst_line(COD_NORMAL_LST_LINE); } }