-/* This structure remembers which files were used */
+/* This structure remembers which .s were used */
typedef struct file_info_struct
{
char *filename;
struct list_info_struct *next;
+ /* Pointer to the file info struct for the high level language
+ source line that belongs here */
+ file_info_type *hll_file;
+
+ /* High level language source line */
+ unsigned int hll_line;
+
+
/* Pointer to any error message associated with this line */
char *message;
- extern char *file_name;
+
static file_info_type *file_info_head;
static file_info_type *
-DEFUN_VOID(file_info)
+DEFUN(file_info, (file_name),
+ char *file_name)
{
/* Find an entry with this file name */
file_info_type *p = file_info_head;
}
+static void
+DEFUN_VOID(new_frag)
+{
+
+ frag_wane(frag_now);
+ frag_new(0);
+
+}
+
void
DEFUN(listing_newline,(ps),
char *ps)
{
char *s = ps;
-
+ extern char *file_name;
static unsigned int last_line =0xffff ;
if (physical_input_line != last_line)
{
last_line = physical_input_line;
- frag_wane(frag_now);
- frag_new(0);
+ new_frag();
+
new = (list_info_type *)malloc(sizeof(list_info_type));
new->frag = frag_now;
new->line = physical_input_line ;
- new->file = file_info();
+ new->file = file_info(file_name);
if (listing_tail)
{
new->next = (list_info_type *)NULL;
new->message = (char *)NULL;
new->edict = EDICT_NONE;
- frag_wane(frag_now);
- frag_new(0);
+ new_frag();
}
}
static char *
-DEFUN(buffer_line,(ptr,line, size),
- list_info_type *ptr AND
+DEFUN(buffer_line,(file, line, size),
+ file_info_type *file AND
char *line AND
unsigned int size)
{
unsigned int count = 0;
+ int c;
+
char *p = line;
- int c = fgetc(ptr->file->file);
+ if (file->file == (FILE*)NULL)
+ {
+ return "";
+ }
+
+ c = fgetc(file->file);
size -= 1; /* leave room for null */
while (c != EOF && c != '\n')
{
*p++ = c;
count++;
- c= fgetc(ptr->file->file);
+ c= fgetc(file->file);
}
if (c == EOF)
{
- rewind(ptr->file->file);
+ rewind(file->file);
+ file->linenum = 0;
+
}
-
+ file->linenum++;
*p++ = 0;
return line;
}
for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr))
{
- if (ptr->sy_frag->line == 0)
+ if (strlen(S_GET_NAME(ptr)) != 0)
{
+ if (ptr->sy_frag->line == 0)
+ {
- printf("%s\n", S_GET_NAME(ptr));
- on_page++;
- listing_page(0);
-
+ printf("%s\n", S_GET_NAME(ptr));
+ on_page++;
+ listing_page(0);
+ }
}
}
}
+void
+DEFUN(print_source,(current_file, list, buffer, width),
+ file_info_type *current_file AND
+ list_info_type *list AND
+ char *buffer AND
+ unsigned int width)
+{
+ if (current_file->file) {
+ while (current_file->linenum < list->hll_line)
+ {
+ char* p = buffer_line(current_file, buffer, width);
+ printf("%4d:%-13s **** %s\n", current_file->linenum, current_file->filename, p);
+ on_page++;
+ listing_page(list);
+ }
+ }
+}
+
void
DEFUN(listing_listing,(name),
char *name)
{
list_info_type *list = head;
+ file_info_type *current_hll_file = (file_info_type *)NULL;
+
unsigned int page= 1;
unsigned int prev = 0;
char *message;
unsigned int addr = 0;
int on_page = 0;
int show_listing = 1;
-
+ unsigned int width;
+
buffer = malloc(LISTING_RHS_WIDTH);
eject = 1;
list = head;
while ( list)
{
- p = buffer_line(list, buffer, LISTING_RHS_WIDTH > paper_width ?
- paper_width : LISTING_RHS_WIDTH);
-
- switch (list->edict) {
- case EDICT_LIST:
- show_listing++;
- break;
- case EDICT_NOLIST:
- show_listing--;
- break;
- case EDICT_EJECT:
- break;
- case EDICT_NONE:
- break;
- case EDICT_TITLE:
- title = list->edict_arg;
- break;
- case EDICT_SBTTL:
- subtitle = list->edict_arg;
- break;
- default:
- abort();
- }
+ width = LISTING_RHS_WIDTH > paper_width ? paper_width :
+ LISTING_RHS_WIDTH;
+
+ switch (list->edict) {
+ case EDICT_LIST:
+ show_listing++;
+ break;
+ case EDICT_NOLIST:
+ show_listing--;
+ break;
+ case EDICT_EJECT:
+ break;
+ case EDICT_NONE:
+ break;
+ case EDICT_TITLE:
+ title = list->edict_arg;
+ break;
+ case EDICT_SBTTL:
+ subtitle = list->edict_arg;
+ break;
+ default:
+ abort();
+ }
if (show_listing > 0)
{
with this line (or lines) */
message = 0;
+ if (list->hll_file)
+ {
+ current_hll_file = list->hll_file;
+ }
+
+ if (current_hll_file && list->hll_line && listing & LISTING_HLL)
+ {
+ print_source(current_hll_file, list, buffer, width);
+ }
+
+ p = buffer_line(list->file, buffer, width);
print_lines(list, p, calc_hex(list));
eject = 1;
}
}
+ else
+ {
+
+ p = buffer_line(list->file, buffer, width);
+ }
+
list = list->next;
}
free(buffer);
}
+
+void
+DEFUN(listing_source_line,(line),
+ unsigned int line)
+{
+ new_frag();
+ listing_tail->hll_line = line;
+ new_frag();
+
+}
+
+void
+DEFUN(listing_source_file,(file),
+ char *file)
+{
+ listing_tail->hll_file = file_info(file);
+}
+
+
+
#else
}
+void DEFUN(listing_source_line,(n),
+unsigned int n)
+{
+
+}
+void DEFUN(listing_source_file, (n),
+char *n)
+{
+
+}
+
+
#endif
+