summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--README.md22
-rwxr-xr-xbuild.sh5
-rwxr-xr-xrun.sh2
-rwxr-xr-xstick.sh4
-rw-r--r--tnslc.tnsl5
6 files changed, 33 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8b6c59f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.o
+build/
+
diff --git a/README.md b/README.md
index 88607eb..d433373 100644
--- a/README.md
+++ b/README.md
@@ -2,14 +2,26 @@
The reference compiler for the TNSL programming language. The compiler is written in TNSL.
+## Requirements:
+- `nasm` - netwide assembler
+ - To bootstrap we build an initial `tnslc` from the `stuck` directory
+ - `tnslc` currently outputs nasm compatible x64 asm
+- `gcc` - c compiler (any will do, just change in build.sh)
+ - we use this to link with libc at the moment until the compiler is in a more complete state
+
## Usage:
-Place the [bootstrap compiler](https://git.cshift.net/CircleShift/ctc) `ctc` in this folder and execute `build.sh tnslc`
-The compiler outputs x86 NASM compatible assembly.
+Bootstrap using the `setup.sh` script, this builds an initial tnslc from the asm in `stuck`
+
+Build using the provided `build.sh` script, it takes the file you want to build as an argument
+- For example: `build.sh tnslc` will build the file named `tnslc.tnsl` and place artifacts in the `build` directory
+
+Run the compiler (once you build it) using the `run.sh` script (works the same way as build.sh) or just copy the
+binary and use it as you please. Run outputs into `build/NEXT` by default
-Examples:
-- `./ctc dummy.tnsl dummy.asm` - Run the bootstrap compiler on the dummy file, output to dummy.asm
-- `./build.sh tnslc` - Build the compiler
+To update the "stuck" version of the compiler we are using for bootstrap, run `stick.sh` after building the
+compiler with `build.sh`. This will copy the tnslc asm from the `build` diretory into the `stuck` directory
+and re-build the bootstrap compiler from it.
## License
diff --git a/build.sh b/build.sh
index d66742f..f4f551f 100755
--- a/build.sh
+++ b/build.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-BUILD_DIR=./out
+BUILD_DIR=./build
ARTIFACT_DIR=$BUILD_DIR/artifacts
mkdir -p $BUILD_DIR
@@ -8,7 +8,8 @@ mkdir -p $ARTIFACT_DIR
filename=$1
filename="${filename%.*}"
-./ctc $filename.tnsl $ARTIFACT_DIR/$filename.asm
+./stuck/tnslc $filename.tnsl
+mv out.asm $ARTIFACT_DIR/$filename.asm
if [ $? -ne 0 ]; then
exit $?
diff --git a/run.sh b/run.sh
index a8cf594..9f768e8 100755
--- a/run.sh
+++ b/run.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-BUILD_DIR=./out/NEXT
+BUILD_DIR=./build/NEXT
ARTIFACT_DIR=$BUILD_DIR/artifacts
mkdir -p $BUILD_DIR
diff --git a/stick.sh b/stick.sh
index b28b04f..871443f 100755
--- a/stick.sh
+++ b/stick.sh
@@ -1,3 +1,7 @@
+rm stuck/*
+cp build/artifacts/tnslc.asm stuck/tnslc.asm
+nasm -f elf64 -g -o stuck/tnslc.o stuck/tnslc.asm
+gcc -g -o stuck/tnslc stuck/tnslc.o
diff --git a/tnslc.tnsl b/tnslc.tnsl
index e69de29..23d2181 100644
--- a/tnslc.tnsl
+++ b/tnslc.tnsl
@@ -0,0 +1,5 @@
+
+/; main [int]
+ return 1
+;/
+