Skip to content

Commit

Permalink
Merge pull request #6 from fabaindaiz/dev
Browse files Browse the repository at this point in the history
Dev: new compiler
  • Loading branch information
fabaindaiz authored Aug 10, 2023
2 parents 9a6e968 + f969285 commit 68eb442
Show file tree
Hide file tree
Showing 34 changed files with 1,670 additions and 1,221 deletions.
72 changes: 36 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
*.annot
*.cmo
*.cma
*.cmi
*.a
*.o
*.cmx
*.cmxs
*.cmxa
*.plist

# ocamlbuild working directory
_build/

# ocamlbuild targets
*.byte
*.native

# oasis generated files
setup.data
setup.log

# Merlin configuring file for Vim and Emacs
.merlin

# Dune generated files
*.install

# Local OPAM switch
_opam/

# Build results
*.s
*.run

# Segmentation fault
*.annot
*.cmo
*.cma
*.cmi
*.a
*.o
*.cmx
*.cmxs
*.cmxa
*.plist

# ocamlbuild working directory
_build/

# ocamlbuild targets
*.byte
*.native

# oasis generated files
setup.data
setup.log

# Merlin configuring file for Vim and Emacs
.merlin

# Dune generated files
*.install

# Local OPAM switch
_opam/

# Build results
*.s
*.run

# Segmentation fault
core
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ocaml.sandbox": {
"kind": "global"
}
}
1,348 changes: 674 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

102 changes: 51 additions & 51 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
# Picked from https://stackoverflow.com/questions/714100/os-detecting-makefile
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
BIN_FORMAT = elf64
CFLAGS ?= -z notext -g
endif
ifeq ($(UNAME_S),Darwin) # for mac
BIN_FORMAT = macho64
CFLAGS ?= -Wl,-no_pie
endif

F = # nothing by default
src = # nothing by default

.PHONY: test

init:
dune build @check

test:
dune exec execs/run_test.exe -- test '$(F)'

ctest:
dune exec execs/run_test.exe -- test '$(F)' -c

compile:
dune exec execs/run_compile.exe $(src)

compile-run: $(subst .src,.run,$(src))
./$<

interp:
dune exec execs/run_interp.exe $(src)

%.run: %.o rt/sys.c
clang -o $@ $(CFLAGS) rt/sys.c $<

%.o: %.s
nasm -f $(BIN_FORMAT) -o $@ $<

%.s: %.src
dune exec execs/run_compile.exe $< > $@

%.exe:
dune build execs/$@

clean: clean-tests
rm -Rf _build

clean-tests:
find bbctests/ -type f -regex '.*\.\(o\|s\|run\|result\)' -delete
# Picked from https://stackoverflow.com/questions/714100/os-detecting-makefile
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
BIN_FORMAT = elf64
CFLAGS ?= -z notext -g
endif
ifeq ($(UNAME_S),Darwin) # for mac
BIN_FORMAT = macho64
CFLAGS ?= -Wl,-no_pie
endif

F = # nothing by default
src = # nothing by default

.PHONY: test

init:
dune build @check

test:
dune exec execs/run_test.exe -- test '$(F)'

ctest:
dune exec execs/run_test.exe -- test '$(F)' -c

compile:
dune exec execs/run_compile.exe $(src)

compile-run: $(subst .src,.run,$(src))
./$<

interp:
dune exec execs/run_interp.exe $(src)

%.run: %.o rt/sys.c
clang -o $@ $(CFLAGS) rt/sys.c $<

%.o: %.s
nasm -f $(BIN_FORMAT) -o $@ $<

%.s: %.src
dune exec execs/run_compile.exe $< > $@

%.exe:
dune build execs/$@

clean: clean-test
rm -Rf _build

clean-test:
find bbctests/ -type f -regex '.*\.\(o\|s\|run\|result\)' -delete
58 changes: 37 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
# corewars-compiler
This software aims to be an easier way to write and optimize code for corewars. corewars-compiler uses its own mini functional language which can then be compiled into optimized redcode.

work in progress

### references

#### compiler
- [BBCStepTester](https://github.com/fabaindaiz/BBCStepTester)

#### standard
- [beginners' guide](https://vyznev.net/corewar/guide.html)
- [1994 Core War Standard](https://corewar.co.uk/standards/icws94.txt)
- [REDCODE REFERENCE](https://corewa.rs/reference/pmars-redcode-94.txt)

#### wariors
- [warriors sorted by type](http://moscova.inria.fr/~doligez/corewar/by-types/idx.htm)
- [warriors sorted by name](http://moscova.inria.fr/~doligez/corewar/by-name/complete.htm)

#### validation
- [ICWS94 validate](http://www.koth.org/planar/post/Validate1.1R.txt)
# corewars-compiler
This software aims to be an easier way to write and optimize code for corewars. corewars-compiler uses its own mini functional language which can then be compiled into optimized redcode.

work in progress

### Requirements
- [BBCStepTester](https://github.com/fabaindaiz/BBCStepTester)

### Intepreters
- [A.R.E.S.](https://corewar.co.uk/ares.htm)
- [PyMARS](https://github.com/rodrigosetti/corewar)


## References

#### Getting started
- [basic manual (spanish)](https://fdist.ucm.es/corewar/CoreWar.pdf)
- [the beginners' guide](https://vyznev.net/corewar/guide.html)
- [my first corewars book](https://www.corewars.org/docs/book1.html)

#### Redcode learning
- [corewars warrior hints](https://es.scribd.com/document/231018699/Core-War-Hints)
- [corewars tips & tricks](https://www.corewars.org/docs/tips.html)

#### Redcode wariors
- [redcode warriors](https://github.com/n1LS/redcode-warriors)
- [warriors sorted by type](http://moscova.inria.fr/~doligez/corewar/by-types/idx.htm)
- [warriors sorted by name](http://moscova.inria.fr/~doligez/corewar/by-name/complete.htm)

#### Redcode reference
- [1994 Core War Standard](https://corewar.co.uk/standards/icws94.txt)
- [REDCODE REFERENCE](https://corewa.rs/reference/pmars-redcode-94.txt)
- [ICWS94 validate](http://www.koth.org/planar/post/Validate1.1R.txt)

#### Coreward koth
- [KotH](http://www.koth.org/koth.html)
- [hills](https://corewar.co.uk/hills.htm)
Loading

0 comments on commit 68eb442

Please sign in to comment.