Skip to content

Commit

Permalink
Added option to generate nasm code and build/test for part 60
Browse files Browse the repository at this point in the history
  • Loading branch information
the-grue committed Jan 7, 2023
1 parent 76b0cb5 commit 6aa392e
Show file tree
Hide file tree
Showing 18 changed files with 1,261 additions and 3 deletions.
40 changes: 37 additions & 3 deletions 60_TripleTest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ HSRCS= data.h decl.h defs.h incdir.h
SRCS= cg.c decl.c expr.c gen.c main.c misc.c \
opt.c scan.c stmt.c sym.c tree.c types.c

ARMSRCS= cg.c decl.c expr.c gen.c main.c misc.c \
SRCN= cgn.c decl.c expr.c gen.c main.c misc.c \
opt.c scan.c stmt.c sym.c tree.c types.c

ARMSRCS= cg_arm.c decl.c expr.c gen.c main.c misc.c \
opt.c scan.c stmt.c sym.c tree.c types.c

cwj: $(SRCS) $(HSRCS)
cc -o cwj -g -Wall $(SRCS)
echo "#define INCDIR \"$(INCDIR)\"" > incdir.h
cc -o cwj -g -Wall -DINCDIR=\"$(INCDIR)\" $(SRCS)

compn: $(SRCN) $(HSRCS)
echo "#define __NASM__ 1" >> incdir.h
cc -D__NASM__ -o compn -g -Wall -DINCDIR=\"$(INCDIR)\" $(SRCN)

cwjarm: $(ARMSRCS) $(HSRCS)
echo "#define INCDIR \"$(INCDIR)\"" > incdir.h
cc -o cwjarm -g -Wall $(ARMSRCS)
cp cwjarm cwj

Expand All @@ -26,8 +35,14 @@ install: cwj
cp cwj $(BINDIR)
chmod +x $(BINDIR)/cwj

installn: compn
mkdir -p $(INCDIR)
rsync -a include/. $(INCDIR)
cp compn $(BINDIR)
chmod +x $(BINDIR)/compn

clean:
rm -f cwj cwj[0-9] cwjarm *.o *.s out a.out incdir.h
rm -f cwj cwj[0-9] cwjarm compn compn[0-9] *.o *.s out a.out incdir.h

test: install tests/runtests
(cd tests; chmod +x runtests; ./runtests)
Expand All @@ -40,6 +55,9 @@ test0: install tests/runtests0 cwj0
armtest: cwjarm tests/runtests
(cd tests; chmod +x runtests; ./runtests)

testn: installn tests/runtestsn
(cd tests; chmod +x runtestsn; ./runtestsn)

# Try to do the triple test
triple: cwj1
size cwj[01]
Expand All @@ -56,3 +74,19 @@ cwj1: cwj0 $(SRCS) $(HSRCS)

cwj0: install $(SRCS) $(HSRCS)
./cwj -o cwj0 $(SRCS)

# Try to do the triple test with nasm
triplen: compn1
size compn[01]

quadn: compn2
size compn[012]

compn2: compn1 $(SRCN) $(HSRCS)
./compn1 -o compn2 $(SRCN)

compn1: compn0 $(SRCN) $(HSRCS)
./compn0 -o compn1 $(SRCN)

compn0: installn $(SRCN) $(HSRCS)
./compn -o compn0 $(SRCN)
Loading

0 comments on commit 6aa392e

Please sign in to comment.