mirror of
https://github.com/nanochess/pretty6502.git
synced 2024-06-02 06:41:33 +00:00
Added support for TMS9900+xas99 (TI-99/4A)
This commit is contained in:
parent
f6e0da6ba0
commit
e410f6f1cd
13
Makefile
Normal file
13
Makefile
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Ultra simple makefile for pretty6502
|
||||||
|
# by Oscar Toledo G.
|
||||||
|
# https://github.com/nanochess/pretty6502
|
||||||
|
#
|
||||||
|
build:
|
||||||
|
@cc pretty6502.c -o pretty6502
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm pretty6502
|
||||||
|
|
||||||
|
love:
|
||||||
|
@echo "...not war"
|
||||||
|
|
3
README
3
README
|
@ -1,4 +1,4 @@
|
||||||
Pretty6502 v0.4 by Oscar Toledo G. http://nanochess.org/
|
Pretty6502 v0.5 by Oscar Toledo G. http://nanochess.org/
|
||||||
|
|
||||||
Executables provided for Mac OS X and Windows.
|
Executables provided for Mac OS X and Windows.
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ Arguments:
|
||||||
-p1 Processor 6502 + DASM syntax (default)
|
-p1 Processor 6502 + DASM syntax (default)
|
||||||
-p2 Processor Z80 + tniASM syntax
|
-p2 Processor Z80 + tniASM syntax
|
||||||
-p3 Processor CP1610 + as1600 syntax (Intellivision)
|
-p3 Processor CP1610 + as1600 syntax (Intellivision)
|
||||||
|
-p4 Processor TMS9900 + xas99 syntax (TI-99/4A)
|
||||||
|
|
||||||
-m8 Start of mnemonic column (default)
|
-m8 Start of mnemonic column (default)
|
||||||
-o16 Start of operand column (default)
|
-o16 Start of operand column (default)
|
||||||
|
|
224
pretty6502.c
224
pretty6502.c
|
@ -13,7 +13,11 @@
|
||||||
** Revision date: Apr/16/2018. Added support for Z80 + tniASM. Solved bug in
|
** Revision date: Apr/16/2018. Added support for Z80 + tniASM. Solved bug in
|
||||||
** processing of apostrophe in operand.
|
** processing of apostrophe in operand.
|
||||||
** Revision date: Apr/17/2018. Added support for CP1610 + as1600 (Intellivision).
|
** Revision date: Apr/17/2018. Added support for CP1610 + as1600 (Intellivision).
|
||||||
** Comments now also include indentation.
|
** Comments now also include indentation. Working in
|
||||||
|
** TMS9900 mode.
|
||||||
|
** Revision date: Apr/18/2018. Added support for TMS9900 + xas99 (TI-99/4A), also
|
||||||
|
** special syntax (comments must be separated by 2
|
||||||
|
** spaces)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -21,9 +25,18 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#define VERSION "v0.4"
|
#define VERSION "v0.5"
|
||||||
int tabs;
|
|
||||||
int processor;
|
int tabs; /* Size of tabs (0 to use spaces) */
|
||||||
|
|
||||||
|
enum {
|
||||||
|
P_UNK,
|
||||||
|
P_6502,
|
||||||
|
P_Z80,
|
||||||
|
P_CP1610,
|
||||||
|
P_TMS9900,
|
||||||
|
P_UNSUPPORTED,
|
||||||
|
} processor; /* Processor/assembler being used (0-4) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** 6502 mnemonics
|
** 6502 mnemonics
|
||||||
|
@ -73,6 +86,22 @@ char *mnemonics_cp1610[] = {
|
||||||
"xor@", "xori", "xorr", NULL,
|
"xor@", "xori", "xorr", NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** TMS9900 mnemonics
|
||||||
|
*/
|
||||||
|
char *mnemonics_tms9900[] = {
|
||||||
|
"a", "ab", "abs", "ai", "andi", "b", "bl", "blwp",
|
||||||
|
"c", "call", "cb", "ci", "ckof", "ckon", "clr", "coc",
|
||||||
|
"czc", "dec", "dect", "div", "idle", "inc", "inct", "inv",
|
||||||
|
"jeq", "jgt", "jh", "jhe", "jl", "jle", "jlt", "jmp",
|
||||||
|
"jnc", "jne", "jno", "joc", "jop", "ldcr", "li", "limi",
|
||||||
|
"lrex", "lwpi", "mov", "movb", "mpy", "neg", "nop", "ori",
|
||||||
|
"pix", "pop", "push", "ret", "rset", "rt", "rtwp", "s",
|
||||||
|
"sb", "sbo", "sbz", "seto", "sla", "slc", "soc", "socb",
|
||||||
|
"sra", "src", "srl", "stcr", "stst", "stwp", "swpb", "szc",
|
||||||
|
"szcb", "tb", "x", "xop", "xor", NULL,
|
||||||
|
};
|
||||||
|
|
||||||
#define DONT_RELOCATE_LABEL 0x01
|
#define DONT_RELOCATE_LABEL 0x01
|
||||||
#define LEVEL_IN 0x02
|
#define LEVEL_IN 0x02
|
||||||
#define LEVEL_OUT 0x04
|
#define LEVEL_OUT 0x04
|
||||||
|
@ -198,6 +227,55 @@ struct directive directives_as1600[] = {
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** xas99 directives
|
||||||
|
*/
|
||||||
|
struct directive directives_xas99[] = {
|
||||||
|
".defm", LEVEL_IN,
|
||||||
|
".else", LEVEL_MINUS,
|
||||||
|
".endif", LEVEL_OUT,
|
||||||
|
".endm", LEVEL_OUT,
|
||||||
|
".error", 0,
|
||||||
|
".ifdef", LEVEL_IN,
|
||||||
|
".ifeq", LEVEL_IN,
|
||||||
|
".ifge", LEVEL_IN,
|
||||||
|
".ifgt", LEVEL_IN,
|
||||||
|
".ifndef", LEVEL_IN,
|
||||||
|
".ifne", LEVEL_IN,
|
||||||
|
"aorg", 0,
|
||||||
|
"bcopy", 0,
|
||||||
|
"bes", 0,
|
||||||
|
"bss", 0,
|
||||||
|
"byte", 0,
|
||||||
|
"cend", 0,
|
||||||
|
"copy", 0,
|
||||||
|
"cseg", 0,
|
||||||
|
"data", 0,
|
||||||
|
"def", DONT_RELOCATE_LABEL,
|
||||||
|
"dend", 0,
|
||||||
|
"dorg", 0,
|
||||||
|
"dseg", 0,
|
||||||
|
"dxop", 0,
|
||||||
|
"end", 0,
|
||||||
|
"equ", DONT_RELOCATE_LABEL,
|
||||||
|
"even", 0,
|
||||||
|
"idt", 0,
|
||||||
|
"list", 0,
|
||||||
|
"load", 0,
|
||||||
|
"page", 0,
|
||||||
|
"pend", 0,
|
||||||
|
"pseg", 0,
|
||||||
|
"ref", 0,
|
||||||
|
"rorg", 0,
|
||||||
|
"save", 0,
|
||||||
|
"sref", 0,
|
||||||
|
"text", 0,
|
||||||
|
"titl", 0,
|
||||||
|
"unl", 0,
|
||||||
|
"xorg", 0,
|
||||||
|
NULL, 0,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Comparison without case
|
** Comparison without case
|
||||||
*/
|
*/
|
||||||
|
@ -220,7 +298,7 @@ int check_opcode(char *p1, char *p2)
|
||||||
int c;
|
int c;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
if (processor == 1) { /* 6502 + DASM */
|
if (processor == P_6502) { /* 6502 + DASM */
|
||||||
for (c = 0; directives_dasm[c].directive != NULL; c++) {
|
for (c = 0; directives_dasm[c].directive != NULL; c++) {
|
||||||
length = strlen(directives_dasm[c].directive);
|
length = strlen(directives_dasm[c].directive);
|
||||||
if ((*p1 == '.' && length == p2 - p1 - 1 && memcmpcase(p1 + 1, directives_dasm[c].directive, p2 - p1 - 1) == 0) || (length == p2 - p1 && memcmpcase(p1, directives_dasm[c].directive, p2 - p1) == 0)) {
|
if ((*p1 == '.' && length == p2 - p1 - 1 && memcmpcase(p1 + 1, directives_dasm[c].directive, p2 - p1 - 1) == 0) || (length == p2 - p1 && memcmpcase(p1, directives_dasm[c].directive, p2 - p1) == 0)) {
|
||||||
|
@ -233,7 +311,7 @@ int check_opcode(char *p1, char *p2)
|
||||||
return -(c + 1);
|
return -(c + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (processor == 2) { /* Z80 + tniASM */
|
if (processor == P_Z80) { /* Z80 + tniASM */
|
||||||
for (c = 0; directives_tniasm[c].directive != NULL; c++) {
|
for (c = 0; directives_tniasm[c].directive != NULL; c++) {
|
||||||
length = strlen(directives_tniasm[c].directive);
|
length = strlen(directives_tniasm[c].directive);
|
||||||
if (length == p2 - p1 && memcmpcase(p1, directives_tniasm[c].directive, p2 - p1) == 0) {
|
if (length == p2 - p1 && memcmpcase(p1, directives_tniasm[c].directive, p2 - p1) == 0) {
|
||||||
|
@ -246,7 +324,7 @@ int check_opcode(char *p1, char *p2)
|
||||||
return -(c + 1);
|
return -(c + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (processor == 3) { /* CP1610 + as1600 */
|
if (processor == P_CP1610) { /* CP1610 + as1600 */
|
||||||
for (c = 0; directives_as1600[c].directive != NULL; c++) {
|
for (c = 0; directives_as1600[c].directive != NULL; c++) {
|
||||||
length = strlen(directives_as1600[c].directive);
|
length = strlen(directives_as1600[c].directive);
|
||||||
if (length == p2 - p1 && memcmpcase(p1, directives_as1600[c].directive, p2 - p1) == 0) {
|
if (length == p2 - p1 && memcmpcase(p1, directives_as1600[c].directive, p2 - p1) == 0) {
|
||||||
|
@ -259,6 +337,19 @@ int check_opcode(char *p1, char *p2)
|
||||||
return -(c + 1);
|
return -(c + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (processor == P_TMS9900) { /* TMS9900 + xas99 */
|
||||||
|
for (c = 0; directives_xas99[c].directive != NULL; c++) {
|
||||||
|
length = strlen(directives_xas99[c].directive);
|
||||||
|
if (length == p2 - p1 && memcmpcase(p1, directives_xas99[c].directive, p2 - p1) == 0) {
|
||||||
|
return c + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (c = 0; mnemonics_tms9900[c] != NULL; c++) {
|
||||||
|
length = strlen(mnemonics_tms9900[c]);
|
||||||
|
if (length == p2 - p1 && memcmpcase(p1, mnemonics_tms9900[c], p2 - p1) == 0)
|
||||||
|
return -(c + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,20 +358,30 @@ int check_opcode(char *p1, char *p2)
|
||||||
*/
|
*/
|
||||||
void request_space(FILE *output, int *current, int new, int force)
|
void request_space(FILE *output, int *current, int new, int force)
|
||||||
{
|
{
|
||||||
|
int base;
|
||||||
|
int tab;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** If already exceeded space...
|
** If already exceeded space...
|
||||||
*/
|
*/
|
||||||
if (*current >= new) {
|
if (*current >= new) {
|
||||||
if (force)
|
if (force == 1) {
|
||||||
fputc(' ', output);
|
fputc(' ', output);
|
||||||
(*current)++;
|
(*current)++;
|
||||||
|
} else if (force == 2 && *current != 0) { /* TMS9900 */
|
||||||
|
fputc(' ', output);
|
||||||
|
(*current)++;
|
||||||
|
fputc(' ', output);
|
||||||
|
(*current)++;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Advance one step at a time
|
** Advance one step at a time
|
||||||
*/
|
*/
|
||||||
|
tab = 0;
|
||||||
|
base = *current;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (tabs == 0) {
|
if (tabs == 0) {
|
||||||
fprintf(output, "%*s", new - *current, "");
|
fprintf(output, "%*s", new - *current, "");
|
||||||
|
@ -288,11 +389,56 @@ void request_space(FILE *output, int *current, int new, int force)
|
||||||
} else {
|
} else {
|
||||||
fputc('\t', output);
|
fputc('\t', output);
|
||||||
*current = (*current + tabs) / tabs * tabs;
|
*current = (*current + tabs) / tabs * tabs;
|
||||||
|
tab = 1;
|
||||||
|
}
|
||||||
|
if (*current >= new) {
|
||||||
|
if (force == 2) { /* TMS9900 */
|
||||||
|
if (tab == 0) {
|
||||||
|
if (*current != 0) {
|
||||||
|
base = *current - base;
|
||||||
|
if (base < 1) {
|
||||||
|
fputc(' ', output);
|
||||||
|
(*current)++;
|
||||||
|
}
|
||||||
|
if (base < 2) {
|
||||||
|
fputc(' ', output);
|
||||||
|
(*current)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (*current >= new)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Check for comment present
|
||||||
|
*/
|
||||||
|
int comment_present(char *start, char *actual, int left_side)
|
||||||
|
{
|
||||||
|
if (processor == P_TMS9900) {
|
||||||
|
if (actual == start && *actual == '*')
|
||||||
|
return 1;
|
||||||
|
if (*actual == '*') {
|
||||||
|
if (actual == start)
|
||||||
|
return 1;
|
||||||
|
if (actual == start + 1 && isspace(actual[-1]))
|
||||||
|
return 1;
|
||||||
|
if (actual >= start + 2) {
|
||||||
|
if (isspace(actual[-2]) && isspace(actual[-1]))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isspace(actual[0]) && isspace(actual[1]) && !left_side)
|
||||||
|
return 1;
|
||||||
|
if (actual[0] == '\t' && !left_side)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (*actual == ';')
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Main program
|
** Main program
|
||||||
|
@ -325,6 +471,7 @@ int main(int argc, char *argv[])
|
||||||
int directives_case;
|
int directives_case;
|
||||||
int indent;
|
int indent;
|
||||||
int something;
|
int something;
|
||||||
|
int comment;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Show usage if less than 3 arguments (program name counts as one)
|
** Show usage if less than 3 arguments (program name counts as one)
|
||||||
|
@ -350,6 +497,7 @@ int main(int argc, char *argv[])
|
||||||
fprintf(stderr, " -p1 Processor 6502 + DASM syntax (default)\n");
|
fprintf(stderr, " -p1 Processor 6502 + DASM syntax (default)\n");
|
||||||
fprintf(stderr, " -p2 Processor Z80 + tniASM syntax\n");
|
fprintf(stderr, " -p2 Processor Z80 + tniASM syntax\n");
|
||||||
fprintf(stderr, " -p3 Processor CP1610 + as1600 syntax (Intellivision(tm))\n");
|
fprintf(stderr, " -p3 Processor CP1610 + as1600 syntax (Intellivision(tm))\n");
|
||||||
|
fprintf(stderr, " -p4 Processor TMS9900 + xas99 syntax (TI-99/4A)\n");
|
||||||
fprintf(stderr, " -m8 Start of mnemonic column (default)\n");
|
fprintf(stderr, " -m8 Start of mnemonic column (default)\n");
|
||||||
fprintf(stderr, " -o16 Start of operand column (default)\n");
|
fprintf(stderr, " -o16 Start of operand column (default)\n");
|
||||||
fprintf(stderr, " -c32 Start of comment column (default)\n");
|
fprintf(stderr, " -c32 Start of comment column (default)\n");
|
||||||
|
@ -378,7 +526,7 @@ int main(int argc, char *argv[])
|
||||||
** Default settings
|
** Default settings
|
||||||
*/
|
*/
|
||||||
style = 0;
|
style = 0;
|
||||||
processor = 1;
|
processor = P_6502;
|
||||||
start_mnemonic = 8;
|
start_mnemonic = 8;
|
||||||
start_operand = 16;
|
start_operand = 16;
|
||||||
start_comment = 32;
|
start_comment = 32;
|
||||||
|
@ -392,6 +540,7 @@ int main(int argc, char *argv[])
|
||||||
/*
|
/*
|
||||||
** Process arguments
|
** Process arguments
|
||||||
*/
|
*/
|
||||||
|
something = 0;
|
||||||
c = 1;
|
c = 1;
|
||||||
while (c < argc - 2) {
|
while (c < argc - 2) {
|
||||||
if (argv[c][0] != '-') {
|
if (argv[c][0] != '-') {
|
||||||
|
@ -407,11 +556,12 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'p': /* Processor */
|
case 'p': /* Processor */
|
||||||
processor = atoi(&argv[c][2]);
|
request = atoi(&argv[c][2]);
|
||||||
if (processor < 0 || processor > 3) {
|
if (request < 0 || request >= P_UNSUPPORTED) {
|
||||||
fprintf(stderr, "Bad processor code: %d\n", processor);
|
fprintf(stderr, "Bad processor code: %d\n", request);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
processor = request;
|
||||||
break;
|
break;
|
||||||
case 'm': /* Mnemonic start */
|
case 'm': /* Mnemonic start */
|
||||||
if (tolower(argv[c][2]) == 'l') {
|
if (tolower(argv[c][2]) == 'l') {
|
||||||
|
@ -424,6 +574,7 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
case 'o': /* Operand start */
|
case 'o': /* Operand start */
|
||||||
start_operand = atoi(&argv[c][2]);
|
start_operand = atoi(&argv[c][2]);
|
||||||
|
something = 1;
|
||||||
break;
|
break;
|
||||||
case 'c': /* Comment start */
|
case 'c': /* Comment start */
|
||||||
start_comment = atoi(&argv[c][2]);
|
start_comment = atoi(&argv[c][2]);
|
||||||
|
@ -497,6 +648,9 @@ int main(int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (something && processor == P_TMS9900) {
|
||||||
|
fprintf(stderr, "Warning: ignoring operand column, not possible because assembler syntax in TMS9900 mode\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Open input file, measure it and read it into buffer
|
** Open input file, measure it and read it into buffer
|
||||||
|
@ -537,6 +691,10 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if (*p1 == '\n') {
|
if (*p1 == '\n') {
|
||||||
p1++;
|
p1++;
|
||||||
|
|
||||||
|
/* Remove trailing spaces */
|
||||||
|
while (p2 > data && *(p2 - 1) != '\0' && isspace(*(p2 - 1)))
|
||||||
|
p2--;
|
||||||
*p2++ = '\0'; /* Break line */
|
*p2++ = '\0'; /* Break line */
|
||||||
request = 1;
|
request = 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -566,8 +724,10 @@ int main(int argc, char *argv[])
|
||||||
current_column = 0;
|
current_column = 0;
|
||||||
p1 = p;
|
p1 = p;
|
||||||
p2 = p1;
|
p2 = p1;
|
||||||
while (*p2 && !isspace(*p2) && *p2 != ';')
|
|
||||||
|
while (*p2 && !isspace(*p2) && !comment_present(p, p2, 1)) {
|
||||||
p2++;
|
p2++;
|
||||||
|
}
|
||||||
if (p2 - p1) { /* Label */
|
if (p2 - p1) { /* Label */
|
||||||
something = 1;
|
something = 1;
|
||||||
fwrite(p1, sizeof(char), p2 - p1, output);
|
fwrite(p1, sizeof(char), p2 - p1, output);
|
||||||
|
@ -576,27 +736,29 @@ int main(int argc, char *argv[])
|
||||||
} else {
|
} else {
|
||||||
current_column = 0;
|
current_column = 0;
|
||||||
}
|
}
|
||||||
while (*p1 && isspace(*p1))
|
while (*p1 && isspace(*p1) && !comment_present(p, p1, 1))
|
||||||
p1++;
|
p1++;
|
||||||
indent = current_level * nesting_space;
|
indent = current_level * nesting_space;
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if (*p1 && *p1 != ';') { /* Mnemonic */
|
if (*p1 && !comment_present(p, p1, 1)) { /* Mnemonic */
|
||||||
p2 = p1;
|
p2 = p1;
|
||||||
while (*p2 && !isspace(*p2) && *p2 != ';')
|
while (*p2 && !isspace(*p2) && !comment_present(p, p2, 0))
|
||||||
p2++;
|
p2++;
|
||||||
if (processor != 0) {
|
if (processor != P_UNK) {
|
||||||
c = check_opcode(p1, p2);
|
c = check_opcode(p1, p2);
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
request = start_mnemonic;
|
request = start_mnemonic;
|
||||||
} else if (c < 0) {
|
} else if (c < 0) {
|
||||||
request = start_mnemonic;
|
request = start_mnemonic;
|
||||||
} else {
|
} else {
|
||||||
if (processor == 1)
|
if (processor == P_6502)
|
||||||
flags = directives_dasm[c - 1].flags;
|
flags = directives_dasm[c - 1].flags;
|
||||||
else if (processor == 2)
|
else if (processor == P_Z80)
|
||||||
flags = directives_tniasm[c - 1].flags;
|
flags = directives_tniasm[c - 1].flags;
|
||||||
else if (processor == 3)
|
else if (processor == P_CP1610)
|
||||||
flags = directives_as1600[c - 1].flags;
|
flags = directives_as1600[c - 1].flags;
|
||||||
|
else if (processor == P_TMS9900)
|
||||||
|
flags = directives_xas99[c - 1].flags;
|
||||||
if (flags & DONT_RELOCATE_LABEL)
|
if (flags & DONT_RELOCATE_LABEL)
|
||||||
request = start_operand;
|
request = start_operand;
|
||||||
else
|
else
|
||||||
|
@ -661,13 +823,16 @@ int main(int argc, char *argv[])
|
||||||
fwrite(p1, sizeof(char), p2 - p1, output);
|
fwrite(p1, sizeof(char), p2 - p1, output);
|
||||||
current_column += p2 - p1;
|
current_column += p2 - p1;
|
||||||
p1 = p2;
|
p1 = p2;
|
||||||
while (*p1 && isspace(*p1))
|
while (*p1 && isspace(*p1) && !comment_present(p, p1, 0))
|
||||||
p1++;
|
p1++;
|
||||||
if (*p1 && *p1 != ';') { /* Operand */
|
if (*p1 && !comment_present(p, p1, 0)) { /* Operand */
|
||||||
|
if (processor == P_TMS9900)
|
||||||
|
request = current_column + 1;
|
||||||
|
else
|
||||||
request = start_operand + indent;
|
request = start_operand + indent;
|
||||||
request_space(output, ¤t_column, request, 1);
|
request_space(output, ¤t_column, request, 1);
|
||||||
p2 = p1;
|
p2 = p1;
|
||||||
while (*p2 && *p2 != ';') {
|
while (*p2 && !comment_present(p, p2, 0)) {
|
||||||
if (*p2 == '"') {
|
if (*p2 == '"') {
|
||||||
p2++;
|
p2++;
|
||||||
while (*p2 && *p2 != '"')
|
while (*p2 && *p2 != '"')
|
||||||
|
@ -690,14 +855,18 @@ int main(int argc, char *argv[])
|
||||||
fwrite(p1, sizeof(char), p2 - p1, output);
|
fwrite(p1, sizeof(char), p2 - p1, output);
|
||||||
current_column += p2 - p1;
|
current_column += p2 - p1;
|
||||||
p1 = p2;
|
p1 = p2;
|
||||||
while (*p1 && isspace(*p1))
|
while (*p1 && isspace(*p1) && !comment_present(p, p1, 0))
|
||||||
p1++;
|
p1++;
|
||||||
}
|
}
|
||||||
if (flags & LEVEL_IN) {
|
if (flags & LEVEL_IN) {
|
||||||
current_level++;
|
current_level++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*p1 == ';') { /* Comment */
|
if (comment_present(p, p1, !something)) { /* Comment */
|
||||||
|
if (processor == P_TMS9900) {
|
||||||
|
while (isspace(*p1))
|
||||||
|
p1++;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Try to keep comments aligned vertically (only works
|
** Try to keep comments aligned vertically (only works
|
||||||
|
@ -720,7 +889,7 @@ int main(int argc, char *argv[])
|
||||||
request = start_mnemonic + indent;
|
request = start_mnemonic + indent;
|
||||||
prev_comment_final_location = request;
|
prev_comment_final_location = request;
|
||||||
}
|
}
|
||||||
request_space(output, ¤t_column, request, 0);
|
request_space(output, ¤t_column, request, (*p1 == ';') ? 0 : 2);
|
||||||
p2 = p1;
|
p2 = p1;
|
||||||
while (*p2)
|
while (*p2)
|
||||||
p2++;
|
p2++;
|
||||||
|
@ -733,6 +902,7 @@ int main(int argc, char *argv[])
|
||||||
continue;
|
continue;
|
||||||
} else if (something == 0) {
|
} else if (something == 0) {
|
||||||
prev_comment_original_location = 0;
|
prev_comment_original_location = 0;
|
||||||
|
prev_comment_final_location = 0;
|
||||||
}
|
}
|
||||||
fputc('\n', output);
|
fputc('\n', output);
|
||||||
while (*p++) ;
|
while (*p++) ;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user