shithub: scc

Download patch

ref: 1ef6b829384110fa3ecac471bfd384e11480c532
parent: 7a5f84aadb1fceda9f03fcebe3449f3ac0004f15
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Sep 8 15:51:46 EDT 2017

[as] Add skeleton for amd64

This is a very basic skeleton and it is sharing a lot
of code with the i386 assembler.

--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 
 include config.mk
 
-DIRS  = inc cc1 cc2 driver lib
+DIRS  = inc cc1 cc2 driver lib as
 
 FORALL = @set -e ;\
 	pwd=$$PWD; \
--- a/as/Makefile
+++ b/as/Makefile
@@ -4,12 +4,13 @@
 include ../config.mk
 include $(LIBDIR)/libdep.mk
 
-OBJ = main.o emit.o
+OBJ = main.o emit.o ins.o
 HDR = ../inc/scc.h as.h
 
 all:
 
 $(OBJ): $(HDR)
+ins.o: ins.h
 
 as: $(OBJ)
 	$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
--- /dev/null
+++ b/as/ins.c
@@ -1,0 +1,10 @@
+
+#include "../inc/scc.h"
+#include "as.h"
+#include "ins.h"
+
+void
+direct(Op *op, Arg *args)
+{
+	emit(cursec, op->bytes, op->size);
+}
--- /dev/null
+++ b/as/ins.h
@@ -1,0 +1,2 @@
+
+Format direct;
--- /dev/null
+++ b/as/target/amd64/ins.c
@@ -1,0 +1,6 @@
+
+#include "../../../inc/scc.h"
+#include "../../as.h"
+#include "ins.h"
+
+TUINT maxaddr = 0xFFFFFFFFFFFFFFFF;
--- /dev/null
+++ b/as/target/amd64/target.mk
@@ -1,0 +1,14 @@
+AMD64_TBL = target/x86/i386.dat target/x86/amd64.dat
+
+target/amd64/instbl.o: target/amd64/ins.h
+
+target/amd64/instbl.c: target/x86/gen.awk $(AMD64_SHDEP)
+	set -e ;\
+	rm -f $@;\
+	trap "rm -f $$$$.c" 0 2 3; \
+	cat $(AMD64_TBL) |\
+	awk -f target/x86/gen.awk > $$$$.c && mv $$$$.c $@
+
+OBJ-amd64 = $(OBJ) \
+	target/amd64/instbl.o \
+	target/i386/ins.o
--- a/as/target/i386/ins.c
+++ b/as/target/i386/ins.c
@@ -3,10 +3,4 @@
 #include "../../as.h"
 #include "ins.h"
 
-TUINT maxaddr = ((TUINT) 1 << 32) -1;
-
-void
-direct(Op *op, Arg *args)
-{
-	emit(cursec, op->bytes, op->size);
-}
+TUINT maxaddr = 0xFFFFFFFF;
--- a/as/target/i386/ins.h
+++ b/as/target/i386/ins.h
@@ -1,1 +1,0 @@
-Format direct;
--- a/as/target/i386/target.mk
+++ b/as/target/i386/target.mk
@@ -1,5 +1,6 @@
 
 target/i386/ins.o: target/i386/ins.h
+target/i386/instbl.o: target/i386/ins.h
 
 target/i386/instbl.c: target/x86/gen.awk target/x86/i386.dat
 	set -e ;\
--- a/as/target/x86/gen.awk
+++ b/as/target/x86/gen.awk
@@ -3,6 +3,7 @@
 	FS = "\t"
 	printf "#include \"../../../inc/scc.h\"\n"\
 	       "#include \"../../as.h\"\n"\
+	       "#include \"../../ins.h\"\n"\
 	       "#include \"ins.h\"\n\n"
 	nop = 0; nvar = 0
 }