# Makefile_64 for nasm assembly code (and corresponding C code)
#             for 64-bit operating systems with 64-bit gcc and nasm
#             on your system  -m64  may be optional on gcc to use 8GB of ram

all: hello_64.out printf1_64.out printf2_64.out \
     intarith_64.out fltarith_64.out fib_64l.out fib_64m.out

hello_64.out: hello_64.asm
	nasm -f elf64 -l hello_64.lst  hello_64.asm
	gcc -m64 -o hello_64  hello_64.o
	./hello_64 > hello_64.out
	cat hello_64.out
	gcc -m64 hello.c
	./a.out > hello.outc
	rm -f a.out

printf1_64.out: printf1_64.asm printf1_64.c
	nasm -f elf64 -l printf1_64.lst  printf1_64.asm
	gcc -m64 -o printf1_64  printf1_64.o
	./printf1_64 > printf1_64.out
	cat printf1_64.out
	gcc -m64 printf1_64.c
	./a.out > printf1_64.outc
	rm -f a.out

printf2_64.out: printf2_64.asm printf2_64.c
	nasm -f elf64 -l printf2_64.lst  printf2_64.asm
	gcc -m64 -o printf2_64  printf2_64.o
	./printf2_64 > printf2_64.out
	cat printf2_64.out
	gcc -m64 printf2_64.c
	./a.out > printf2_64.outc
	rm -f a.out

intarith_64.out: intarith_64.asm intarith_64.c
	nasm -f elf64 -l intarith_64.lst  intarith_64.asm
	gcc -m64 -o intarith_64  intarith_64.o
	./intarith_64 > intarith_64.out
	cat intarith_64.out
	gcc -m64 intarith_64.c
	./a.out > intarith_64.outc
	rm -f a.out

fltarith_64.out: fltarith_64.asm fltarith_64.c
	nasm -f elf64 -l fltarith_64.lst  fltarith_64.asm
	gcc -m64 -o fltarith_64  fltarith_64.o
	./fltarith_64 > fltarith_64.out
	cat fltarith_64.out
	gcc -m64 fltarith_64.c
	./a.out > fltarith_64.outc
	rm -f a.out

fib_64l.out: fib_64l.asm fib.c
	nasm -f elf64 -l fib_64l.lst  fib_64l.asm
	gcc -m64 -o fib_64l  fib_64l.o
	./fib_64l > fib_64l.out
	cat fib_64l.out
	gcc -m64 fib.c
	./a.out > fib.outc
	rm -f a.out

fib_64m.out: fib_64m.asm
	nasm -f elf64 -l fib_64m.lst  fib_64m.asm
	gcc -m64 -o fib_64m  fib_64m.o
	./fib_64m > fib_64m.out
	cat fib_64m.out


recompile:
	rm -f *.out
	rm -f *.outc
	make all

clean:  # for moving to another platform, keeping results
	rm -f hello_64
	rm -f printf1_64
	rm -f printf2_64
	rm -f intarith_64
	rm -f fltarith_64
	rm -f fib_64l
	rm -f fib_64m
	rm -f a.out
	rm -f *~
	rm -f core*
	rm -f *.o

initial:
	rm -f *_64.out
	rm -f *_64.outc
	rm -f *_64.lst
	rm -f *.s
	make clean

web:
	chgrp cseeweb *
	chmod go+rx *
	chmod g+w *