scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit dd5fa13571a7ac1f16c88b3590502e1ed4e8b359
parent e2a1c0856e8aa4c9d6d480ec574900d829cb54de
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  8 Sep 2017 19:51:46 +0200

[as] Add skeleton for amd64

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

Diffstat:
Makefile | 2+-
as/Makefile | 3++-
as/ins.c | 10++++++++++
as/ins.h | 2++
as/target/amd64/ins.c | 6++++++
as/target/amd64/ins.h | 0
as/target/amd64/target.mk | 14++++++++++++++
as/target/i386/ins.c | 8+-------
as/target/i386/ins.h | 1-
as/target/i386/target.mk | 1+
as/target/x86/amd64.dat | 0
as/target/x86/gen.awk | 1+
12 files changed, 38 insertions(+), 10 deletions(-)

diff --git 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; \ diff --git a/as/Makefile b/as/Makefile @@ -4,12 +4,13 @@ LIBDIR = ../lib/scc 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 $@ diff --git a/as/ins.c b/as/ins.c @@ -0,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); +} diff --git a/as/ins.h b/as/ins.h @@ -0,0 +1,2 @@ + +Format direct; diff --git a/as/target/amd64/ins.c b/as/target/amd64/ins.c @@ -0,0 +1,6 @@ + +#include "../../../inc/scc.h" +#include "../../as.h" +#include "ins.h" + +TUINT maxaddr = 0xFFFFFFFFFFFFFFFF; diff --git a/as/target/amd64/ins.h b/as/target/amd64/ins.h diff --git a/as/target/amd64/target.mk b/as/target/amd64/target.mk @@ -0,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 diff --git 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; diff --git a/as/target/i386/ins.h b/as/target/i386/ins.h @@ -1 +0,0 @@ -Format direct; diff --git 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 ;\ diff --git a/as/target/x86/amd64.dat b/as/target/x86/amd64.dat diff --git a/as/target/x86/gen.awk b/as/target/x86/gen.awk @@ -3,6 +3,7 @@ BEGIN { 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 }