shithub: scc

Download patch

ref: 0ee0d67347b6c76243b45e02504fc16d93637b07
parent: d861d0e37084374769dd70f61f1f6c1185bedacb
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Sep 9 03:17:59 EDT 2017

[as] Move pack() to emit.c

It is better to keep ins.c files only for instruction formats

--- a/as/as.h
+++ b/as/as.h
@@ -56,6 +56,7 @@
 extern void emit(Section *sec, char *bytes, int nbytes);
 extern Section *section(char *name);
 extern void incpc(int siz);
+extern char *pack(TUINT v, int n, int inc);
 
 extern Section *cursec;
 extern int nr_ins;
--- a/as/emit.c
+++ b/as/emit.c
@@ -27,6 +27,21 @@
 
 int pass;
 
+char *
+pack(TUINT v, int n, int inc)
+{
+	static char buf[sizeof(TUINT)];
+	int idx;
+
+	idx = (inc < 0) ? n-1 : 0;
+	while (n--) {
+		buf[idx] = v;
+		idx += inc;
+		v >>= 8;
+	}
+	return buf;
+}
+
 static void
 isect(Section *sec)
 {
--- a/as/ins.c
+++ b/as/ins.c
@@ -8,21 +8,6 @@
 	emit(cursec, op->bytes, op->size);
 }
 
-char *
-pack(TUINT v, int n, int inc)
-{
-	static char buf[sizeof(TUINT)];
-	int idx;
-
-	idx = (inc < 0) ? n-1 : 0;
-	while (n--) {
-		buf[idx] = v;
-		idx += inc;
-		v >>= 8;
-	}
-	return buf;
-}
-
 void
 def(Arg *args, int siz)
 {