shithub: scc

Download patch

ref: e4f73e4cbfcc3ced54492a690a411d74aa0c7658
parent: 395a3c572792c6270427954ff55b76c6d976a479
parent: 90587cbec9a3ffba0aee86c7be5503447f711f6e
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Feb 1 15:59:37 EST 2018

Merge remote-tracking branch 'simple-cc/master'

--- a/as/ins.c
+++ b/as/ins.c
@@ -247,3 +247,14 @@
 {
 	addinput(args[0]->sym->name.buf);
 }
+
+void
+att(Op *op, Node **args)
+{
+	Symbol *sym = args[0]->sym;
+	extern int left2right;
+
+	if ((sym->flags & FABS) == 0)
+		error("align expression is not an absolute expression");
+	left2right = sym->value;
+}
--- a/as/main.c
+++ b/as/main.c
@@ -105,6 +105,7 @@
 main(int argc, char *argv[])
 {
 	char **p;
+	extern int left2right;
 
 	outfile = "a.out";
 
@@ -111,6 +112,12 @@
 	ARGBEGIN {
 	case 'o':
 		outfile = EARGF(usage());
+		break;
+	case 'l':
+		left2right = 1;
+		break;
+	case 'r':
+		left2right = 1;
 		break;
 	default:
 		usage();
--- a/as/parser.c
+++ b/as/parser.c
@@ -299,14 +299,24 @@
 getargs(char *s)
 {
 	Node **ap;
-	static Node *args[NARGS];
+	extern int left2right;
+	static Node *args[NARGS+1];
 
 	if (!s)
 		return NULL;
 
-	for (ap = args; ap < &args[NARGS-1]; ++ap) {
-		if ((*ap = operand(&s)) == NULL)
-			return args;
+	if (!left2right) {
+		ap = args;
+		do {
+			if ((*ap = operand(&s)) == NULL)
+				return args;
+		} while (++ap < &args[NARGS]);
+	} else {
+		ap = &args[NARGS];
+		do {
+			if ((*--ap = operand(&s)) == NULL)
+				return ap+1;
+		} while (ap > args+1);
 	}
 	error("too many arguments in one instruction");
 }
@@ -411,6 +421,7 @@
 		if (c == '/') {
 			if ((c = getc(fp)) != '*') {
 				ungetc(c, fp);
+				c = '/';
 			} else {
 				comment(fp);
 				c = ' ';
@@ -418,9 +429,11 @@
 		} else if (c > UCHAR_MAX) {
 			error("invalid character '%x'", c);
 		}
-		if (bp == &buff[MAXLINE])
+		if (bp == &buff[MAXLINE-1])
 			error("line too long");
 	}
+	*bp = '\0';
+
 	return bp - buff;
 }
 
--- a/as/target/x80/x80.dat
+++ b/as/target/x80/x80.dat
@@ -31,6 +31,7 @@
 .STRING	string+	0	none	string	Z80,R800,GB80
 .ASCII	string+	0	none	ascii	Z80,R800,GB80
 .ALIGN	imm16+	0	none	align	Z80,R800,GB80
+.ATT	imm8	0	none	att	Z80,R800,GB80
 .END	none	0	none	end	Z80,R800,GB80
 .INCLUDE	string	0	none	include	Z80,R800,GB80
 
--- a/as/target/x80/z80.c
+++ b/as/target/x80/z80.c
@@ -8,6 +8,7 @@
 
 TUINT maxaddr = 0xFFFFFFFF;
 int endian = LITTLE_ENDIAN;
+int left2right = 0;
 
 void
 iarch(void)
--- a/as/target/x86/amd64.c
+++ b/as/target/x86/amd64.c
@@ -5,6 +5,7 @@
 
 TUINT maxaddr = 0xFFFFFFFFFFFFFFFF;
 int endian = LITTLE_ENDIAN;
+int left2right = 0;
 
 void
 iarch(void)
--- a/as/target/x86/i386.c
+++ b/as/target/x86/i386.c
@@ -6,6 +6,7 @@
 
 TUINT maxaddr = 0xFFFFFFFF;
 int endian = LITTLE_ENDIAN;
+int left2right = 0;
 
 void
 iarch(void)