mirror of
https://github.com/fachat/xa65.git
synced 2024-06-09 14:29:29 +00:00
start working on lint output
This commit is contained in:
parent
c8e38145a5
commit
07ab497177
|
@ -945,7 +945,7 @@ static void usage(int default816, FILE *fp)
|
||||||
" -l filename sets labellist filename, default is none\n"
|
" -l filename sets labellist filename, default is none\n"
|
||||||
" -P filename sets filename for listing, default is none, '-' is stdout\n"
|
" -P filename sets filename for listing, default is none, '-' is stdout\n"
|
||||||
" -F format sets format for listing, default is plain, 'html' is current only other\n"
|
" -F format sets format for listing, default is plain, 'html' is current only other\n"
|
||||||
" supported format\n"
|
" supported format. Use 'lint' resp. 'linthtml' for linted source output\n"
|
||||||
" -r adds crossreference list to labellist (if `-l' given)\n"
|
" -r adds crossreference list to labellist (if `-l' given)\n"
|
||||||
" -M allow ``:'' to appear in comments for MASM compatibility\n"
|
" -M allow ``:'' to appear in comments for MASM compatibility\n"
|
||||||
" -Xcompatset set compatibility flags for other assemblers, known values are:\n"
|
" -Xcompatset set compatibility flags for other assemblers, known values are:\n"
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include "xal.h"
|
#include "xal.h"
|
||||||
#include "xat.h"
|
#include "xat.h"
|
||||||
|
|
||||||
|
#include "xalisting.h"
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
/* this is the listing code
|
/* this is the listing code
|
||||||
|
@ -46,6 +48,7 @@ static int list_last_lineno = 0; /* current line number */
|
||||||
static char *list_filenamep = NULL; /* current file name pointer */
|
static char *list_filenamep = NULL; /* current file name pointer */
|
||||||
|
|
||||||
static int list_numbytes = 8;
|
static int list_numbytes = 8;
|
||||||
|
static int list_lint = 0;
|
||||||
|
|
||||||
static int list_string(char *buf, char *string);
|
static int list_string(char *buf, char *string);
|
||||||
static int list_tokens(char *buf, signed char *input, int len);
|
static int list_tokens(char *buf, signed char *input, int len);
|
||||||
|
@ -175,8 +178,17 @@ void list_flush() {
|
||||||
void list_start(const char *formatname) {
|
void list_start(const char *formatname) {
|
||||||
formatp = &def_format;
|
formatp = &def_format;
|
||||||
|
|
||||||
if (formatname != NULL && strcmp("html", formatname) == 0) {
|
if (formatname != NULL) {
|
||||||
formatp = &html_format;
|
if (strcmp("linthtml", formatname) == 0) {
|
||||||
|
formatp = &html_format;
|
||||||
|
list_setlint();
|
||||||
|
} else
|
||||||
|
if (strcmp("html", formatname) == 0) {
|
||||||
|
formatp = &html_format;
|
||||||
|
} else
|
||||||
|
if (strcmp("lint", formatname) == 0) {
|
||||||
|
list_setlint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listfp != NULL) {
|
if (listfp != NULL) {
|
||||||
|
@ -195,6 +207,11 @@ void list_setbytes(int number_of_bytes_per_line) {
|
||||||
list_numbytes = number_of_bytes_per_line;
|
list_numbytes = number_of_bytes_per_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set to lint mode
|
||||||
|
void list_setlint() {
|
||||||
|
list_lint = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* set line number for the coming listing output */
|
/* set line number for the coming listing output */
|
||||||
void list_line(int l) {
|
void list_line(int l) {
|
||||||
list_lineno = l;
|
list_lineno = l;
|
||||||
|
@ -208,7 +225,7 @@ void list_filename(char *fname) {
|
||||||
list_last_lineno = 0;
|
list_last_lineno = 0;
|
||||||
|
|
||||||
/* Hack */
|
/* Hack */
|
||||||
if (listfp != NULL) {
|
if (listfp != NULL && !list_lint) {
|
||||||
fprintf(listfp, "\n%s\n\n", fname);
|
fprintf(listfp, "\n%s\n\n", fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,8 +301,6 @@ void do_listing(signed char *listing, int listing_len, signed char *bincode, int
|
||||||
// could be extended to include the preamble...
|
// could be extended to include the preamble...
|
||||||
if (formatp->start_line != NULL) formatp->start_line();
|
if (formatp->start_line != NULL) formatp->start_line();
|
||||||
|
|
||||||
buf = list_preamble(buf, list_lineno, lst_seg, lst_pc);
|
|
||||||
|
|
||||||
// check if we have labels, so we can adjust the max printable number of
|
// check if we have labels, so we can adjust the max printable number of
|
||||||
// bytes in the last line
|
// bytes in the last line
|
||||||
int num_last_line = 11;
|
int num_last_line = 11;
|
||||||
|
@ -294,54 +309,62 @@ void do_listing(signed char *listing, int listing_len, signed char *bincode, int
|
||||||
// we have label definition
|
// we have label definition
|
||||||
num_last_line = 8;
|
num_last_line = 8;
|
||||||
}
|
}
|
||||||
int overflow = 0;
|
|
||||||
|
|
||||||
/* binary output (up to 8 byte. If more than 8 byte, print 7 plus "..." */
|
if (list_lint) {
|
||||||
n_hexb = bincode_len;
|
buf = buf + list_nchar(buf, ' ', (num_last_line - 8) * 3);
|
||||||
if (list_numbytes != 0 && n_hexb >= list_numbytes) {
|
} else {
|
||||||
n_hexb = list_numbytes-1;
|
buf = list_preamble(buf, list_lineno, lst_seg, lst_pc);
|
||||||
overflow = 1;
|
|
||||||
}
|
int overflow = 0;
|
||||||
for (i = 0; i < n_hexb; i++) {
|
|
||||||
buf = buf + list_byte(buf, bincode[i]);
|
/* binary output (up to 8 byte. If more than 8 byte, print 7 plus "..." */
|
||||||
buf = buf + list_sp(buf);
|
n_hexb = bincode_len;
|
||||||
if ( (i%16) == 15) {
|
if (list_numbytes != 0 && n_hexb >= list_numbytes) {
|
||||||
// make a break
|
n_hexb = list_numbytes-1;
|
||||||
|
overflow = 1;
|
||||||
|
}
|
||||||
|
for (i = 0; i < n_hexb; i++) {
|
||||||
|
buf = buf + list_byte(buf, bincode[i]);
|
||||||
|
buf = buf + list_sp(buf);
|
||||||
|
if ( (i%16) == 15) {
|
||||||
|
// make a break
|
||||||
|
buf[0] = 0;
|
||||||
|
fprintf(listfp, "%s\n", outline);
|
||||||
|
if (formatp->end_line != NULL) formatp->end_line();
|
||||||
|
if (formatp->start_line != NULL) formatp->start_line();
|
||||||
|
buf = outline;
|
||||||
|
buf = list_preamble(buf, list_lineno, lst_seg, lst_pc + i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (overflow) {
|
||||||
|
// are we at the last byte?
|
||||||
|
if (n_hexb + 1 == bincode_len) {
|
||||||
|
// just print the last byte
|
||||||
|
buf = buf + list_byte(buf, bincode[i]);
|
||||||
|
buf = buf + list_sp(buf);
|
||||||
|
} else {
|
||||||
|
// display "..."
|
||||||
|
buf = buf + list_nchar(buf, '.', 3);
|
||||||
|
}
|
||||||
|
n_hexb++;
|
||||||
|
}
|
||||||
|
i = n_hexb % 16;
|
||||||
|
if (i > num_last_line) {
|
||||||
|
// make a break (Note: with original PC, as now the assembler text follows
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
fprintf(listfp, "%s\n", outline);
|
fprintf(listfp, "%s\n", outline);
|
||||||
if (formatp->end_line != NULL) formatp->end_line();
|
if (formatp->end_line != NULL) formatp->end_line();
|
||||||
if (formatp->start_line != NULL) formatp->start_line();
|
if (formatp->start_line != NULL) formatp->start_line();
|
||||||
buf = outline;
|
buf = outline;
|
||||||
buf = list_preamble(buf, list_lineno, lst_seg, lst_pc + i + 1);
|
buf = list_preamble(buf, list_lineno, lst_seg, lst_pc);
|
||||||
}
|
i = 0;
|
||||||
}
|
}
|
||||||
if (overflow) {
|
i = num_last_line - i;
|
||||||
// are we at the last byte?
|
buf = buf + list_nchar(buf, ' ', i * 3);
|
||||||
if (n_hexb + 1 == bincode_len) {
|
|
||||||
// just print the last byte
|
|
||||||
buf = buf + list_byte(buf, bincode[i]);
|
|
||||||
buf = buf + list_sp(buf);
|
|
||||||
} else {
|
|
||||||
// display "..."
|
|
||||||
buf = buf + list_nchar(buf, '.', 3);
|
|
||||||
}
|
|
||||||
n_hexb++;
|
|
||||||
}
|
|
||||||
i = n_hexb % 16;
|
|
||||||
if (i > num_last_line) {
|
|
||||||
// make a break (Note: with original PC, as now the assembler text follows
|
|
||||||
buf[0] = 0;
|
|
||||||
fprintf(listfp, "%s\n", outline);
|
|
||||||
if (formatp->end_line != NULL) formatp->end_line();
|
|
||||||
if (formatp->start_line != NULL) formatp->start_line();
|
|
||||||
buf = outline;
|
|
||||||
buf = list_preamble(buf, list_lineno, lst_seg, lst_pc);
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
i = num_last_line - i;
|
|
||||||
buf = buf + list_nchar(buf, ' ', i * 3);
|
|
||||||
|
|
||||||
buf = buf + list_sp(buf);
|
buf = buf + list_sp(buf);
|
||||||
|
|
||||||
|
} // end list_lint
|
||||||
|
|
||||||
buf += list_tokens(buf, listing + 3, listing_len - 3);
|
buf += list_tokens(buf, listing + 3, listing_len - 3);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#ifndef __XA65_XALISTING_H__
|
#ifndef __XA65_XALISTING_H__
|
||||||
#define __XA65_XALISTING_H__
|
#define __XA65_XALISTING_H__
|
||||||
|
|
||||||
void list_start(char *formatname); //either NULL or "html"
|
void list_start(const char *formatname); //either NULL or "html"
|
||||||
void list_end();
|
void list_end();
|
||||||
|
|
||||||
void list_flush(); // debug helper
|
void list_flush(); // debug helper
|
||||||
|
@ -31,4 +31,7 @@ void list_filename(char *fname);/* set file name for the coming listing output *
|
||||||
// list a single line/token set
|
// list a single line/token set
|
||||||
void do_listing(signed char *listing, int listing_len, signed char *bincode, int bincode_len);
|
void do_listing(signed char *listing, int listing_len, signed char *bincode, int bincode_len);
|
||||||
|
|
||||||
|
void list_setbytes(int number_of_bytes_per_line);
|
||||||
|
void list_setlint();
|
||||||
|
|
||||||
#endif /* __XA65_XALISTING_H__ */
|
#endif /* __XA65_XALISTING_H__ */
|
||||||
|
|
|
@ -56,9 +56,6 @@ static void tg_hex(signed char*,int*,int*);
|
||||||
static void tg_oct(signed char*,int*,int*);
|
static void tg_oct(signed char*,int*,int*);
|
||||||
static void tg_bin(signed char*,int*,int*);
|
static void tg_bin(signed char*,int*,int*);
|
||||||
static int t_p2(signed char *t, int *ll, int fl, int *al);
|
static int t_p2(signed char *t, int *ll, int fl, int *al);
|
||||||
//static void do_listing(signed char *listing, int listing_len, signed char *bincode, int bincode_len);
|
|
||||||
|
|
||||||
void list_setbytes(int number_of_bytes_per_line);
|
|
||||||
|
|
||||||
/* assembly mnemonics and pseudo-op tokens */
|
/* assembly mnemonics and pseudo-op tokens */
|
||||||
/* ina and dea don't work yet */
|
/* ina and dea don't work yet */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user