#include "input-file.h"
#include "targ-cpu.h"
+char *malloc();
+
#ifndef NO_LISTING
#ifndef LISTING_HEADER
#define LISTING_HEADER "GAS LISTING"
int linenum;
FILE *file;
struct file_info_struct *next;
+ int end_pending;
+
} file_info_type ;
file_info_type *hll_file;
/* High level language source line */
- unsigned int hll_line;
+ int hll_line;
/* Pointer to any error message associated with this line */
char *message)
{
unsigned int l = strlen(name) + strlen(message)+1;
- char *n = malloc(l);
+ char *n = (char*)malloc(l);
strcpy(n,name);
strcat(n,message);
if(listing_tail != (list_info_type *)NULL)
p->filename = xmalloc(strlen(file_name)+1);
strcpy(p->filename, file_name);
p->linenum = 0;
- p->file = fopen(p->filename,"r");
+ p->end_pending = 0;
+
+ p->file = fopen(p->filename,"rb");
+if (p->file) fgetc(p->file);
+
+
+
return p;
}
new->next = (list_info_type *)NULL;
new->message = (char *)NULL;
new->edict = EDICT_NONE;
+ new->hll_file = (file_info_type*)NULL;
+ new->hll_line = 0;
new_frag();
}
}
-
+/*
+ This function returns the next source line from the file supplied,
+ truncated to size. It appends a fake line to the end of each input
+ file to make
+*/
static char *
DEFUN(buffer_line,(file, line, size),
int c;
char *p = line;
+
+ /* If we couldn't open the file, return an empty line */
if (file->file == (FILE*)NULL)
{
return "";
}
-
+
+ if (file->linenum == 0)
+ rewind(file->file);
+
+ if (file->end_pending == 10) {
+ *p ++ = '\n';
+ fseek(file->file, 0,0 );
+ file->linenum = 0;
+ file->end_pending = 0;
+ }
c = fgetc(file->file);
+
+
size -= 1; /* leave room for null */
+
while (c != EOF && c != '\n')
{
if (count < size)
count++;
c= fgetc(file->file);
+
}
if (c == EOF)
{
- rewind(file->file);
- file->linenum = 0;
-
+ file->end_pending ++;
+ *p++ = '.';
+ *p++ = '.';
+ *p++ = '.';
}
file->linenum++;
*p++ = 0;
address = frag_ptr->fr_address;
}
- sprintf(data_buffer + data_buffer_size, "%02X",(frag_ptr->fr_literal[byte_in_frag]) & 0xff);
+ sprintf(data_buffer + data_buffer_size,
+ "%02X",
+ (frag_ptr->fr_literal[byte_in_frag]) & 0xff);
data_buffer_size += 2;
byte_in_frag++;
}
+ {
+ unsigned int var_rep_max = byte_in_frag;
+ unsigned int var_rep_idx = byte_in_frag;
+
/* Print as many bytes from the variable part as is sensible */
while (byte_in_frag < frag_ptr->fr_var * frag_ptr->fr_offset
&& data_buffer_size < sizeof(data_buffer)-10)
{
address = frag_ptr->fr_address;
}
+sprintf(data_buffer + data_buffer_size,
+ "%02X",
+ (frag_ptr->fr_literal[var_rep_idx]) & 0xff);
+#if 0
data_buffer[data_buffer_size++] = '*';
data_buffer[data_buffer_size++] = '*';
+#endif
+ data_buffer_size +=2;
+ var_rep_idx ++;
byte_in_frag++;
+
+ if (var_rep_idx >= frag_ptr->fr_var)
+ var_rep_idx = var_rep_max;
}
+ }
+
frag_ptr = frag_ptr->fr_next;
}
data_buffer[data_buffer_size++] = 0;
{
if (ptr->sy_frag->line)
{
+ if (S_GET_NAME(ptr))
+ {
+
if (strlen(S_GET_NAME(ptr)))
{
printf("%20s:%-5d %2d:%08x %s \n",
S_GET_SEGMENT(ptr),
S_GET_VALUE(ptr),
S_GET_NAME(ptr));
+ }
+
+ else
+ {
+ printf("%20s:%-5d %2d:%08x\n",
+ ptr->sy_frag->line->file->filename,
+ ptr->sy_frag->line->line,
+ S_GET_SEGMENT(ptr),
+ S_GET_VALUE(ptr));
+
+ }
+
on_page++;
listing_page(0);
}
for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr))
{
- if (ptr && strlen(S_GET_NAME(ptr)) != 0)
+ if (S_GET_NAME(ptr) && strlen(S_GET_NAME(ptr)) != 0)
{
if (ptr->sy_frag->line == 0)
{
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);
+ 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);
}
}
}
+/* Sometimes the user doesn't want to be bothered by the debugging
+ records inserted by the compiler, see if the line is suspicioous */
+
+static int
+DEFUN(debugging_pseudo,(line),
+ char *line)
+{
+ while (isspace(*line))
+ line++;
+
+ if(*line != '.') return 0;
+
+ line++;
+
+ if (strncmp(line, "def",3) == 0) return 1;
+ if (strncmp(line, "val",3) == 0) return 1;
+ if (strncmp(line, "scl",3) == 0) return 1;
+ if (strncmp(line, "line",4) == 0) return 1;
+ if (strncmp(line, "endef",5) == 0) return 1;
+ if (strncmp(line, "ln",2) ==0) return 1;
+ if (strncmp(line, "type",4) ==0) return 1;
+ if (strncmp(line, "size",4) == 0) return 1;
+ if (strncmp(line, "dim",3) ==0) return 1;
+ if (strncmp(line, "tag",3) == 0) return 1;
+
+ return 0;
+
+}
+
void
DEFUN(listing_listing,(name),
char *name)
while ( list)
{
width = LISTING_RHS_WIDTH > paper_width ? paper_width :
- LISTING_RHS_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();
- }
+ 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)
{
p = buffer_line(list->file, buffer, width);
- print_lines(list, p, calc_hex(list));
+ if (! ((listing & LISTING_NODEBUG) && debugging_pseudo(p)))
+ {
+ print_lines(list, p, calc_hex(list));
+ }
if (list->edict == EDICT_EJECT)
{
void
DEFUN_VOID(listing_flags)
{
+ while ( (*input_line_pointer++) && (*input_line_pointer != '\n') )
+ input_line_pointer++;
}
void
if (paper_height < 0 || paper_height > 1000)
{
paper_height = 0;
- as_warn("strantge paper height, set to no form");
+ as_warn("strange paper height, set to no form");
}
if (*input_line_pointer == ',')
{
{
s_ignore();
}
-void DEFUN(listing_psize)
+void DEFUN_VOID(listing_psize)
{
s_ignore();
}