diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..a5ab851 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/sbin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-x64", + "configurationProvider": "ms-vscode.makefile-tools" + } + ], + "version": 4 +} diff --git a/09 - Santa Cruz/Santa Cruz notes b/09-Santa Cruz/Santa Cruz notes similarity index 100% rename from 09 - Santa Cruz/Santa Cruz notes rename to 09-Santa Cruz/Santa Cruz notes diff --git a/13 - Algiers/Algiers notes b/13-Algiers/Algiers notes similarity index 100% rename from 13 - Algiers/Algiers notes rename to 13-Algiers/Algiers notes diff --git a/14 - Vladivostok/Vladivostok.asm b/14-Vladivostok/Vladivostok.asm similarity index 100% rename from 14 - Vladivostok/Vladivostok.asm rename to 14-Vladivostok/Vladivostok.asm diff --git a/15 - Bangalore/Bangalore notes.asm b/15-Bangalore/Bangalore notes.asm similarity index 100% rename from 15 - Bangalore/Bangalore notes.asm rename to 15-Bangalore/Bangalore notes.asm diff --git a/16 - Lagos/Lagos Solution.asm b/16-Lagos/Lagos Solution.asm similarity index 100% rename from 16 - Lagos/Lagos Solution.asm rename to 16-Lagos/Lagos Solution.asm diff --git a/16 - Lagos/Lagos notes.asm b/16-Lagos/Lagos notes.asm similarity index 100% rename from 16 - Lagos/Lagos notes.asm rename to 16-Lagos/Lagos notes.asm diff --git a/16 - Lagos/Lagos.asm b/16-Lagos/Lagos.asm similarity index 100% rename from 16 - Lagos/Lagos.asm rename to 16-Lagos/Lagos.asm diff --git a/16 - Lagos/disassemble.py b/16-Lagos/disassemble.py similarity index 100% rename from 16 - Lagos/disassemble.py rename to 16-Lagos/disassemble.py diff --git a/16 - Lagos/generate_lut.py b/16-Lagos/generate_lut.py similarity index 100% rename from 16 - Lagos/generate_lut.py rename to 16-Lagos/generate_lut.py diff --git a/16 - Lagos/insgen.py b/16-Lagos/insgen.py similarity index 100% rename from 16 - Lagos/insgen.py rename to 16-Lagos/insgen.py diff --git a/16 - Lagos/instructions.asm b/16-Lagos/instructions.asm similarity index 100% rename from 16 - Lagos/instructions.asm rename to 16-Lagos/instructions.asm diff --git a/16 - Lagos/lut.txt b/16-Lagos/lut.txt similarity index 100% rename from 16 - Lagos/lut.txt rename to 16-Lagos/lut.txt diff --git a/16 - Lagos/lut2.txt b/16-Lagos/lut2.txt similarity index 100% rename from 16 - Lagos/lut2.txt rename to 16-Lagos/lut2.txt diff --git a/16 - Lagos/memory_clean.bin b/16-Lagos/memory_clean.bin similarity index 100% rename from 16 - Lagos/memory_clean.bin rename to 16-Lagos/memory_clean.bin diff --git a/16 - Lagos/memory_clean.txt b/16-Lagos/memory_clean.txt similarity index 100% rename from 16 - Lagos/memory_clean.txt rename to 16-Lagos/memory_clean.txt diff --git a/16 - Lagos/paygen.py b/16-Lagos/paygen.py similarity index 100% rename from 16 - Lagos/paygen.py rename to 16-Lagos/paygen.py diff --git a/17 - Chernobyl/.clang-format b/17-Chernobyl/.clang-format similarity index 100% rename from 17 - Chernobyl/.clang-format rename to 17-Chernobyl/.clang-format diff --git a/17 - Chernobyl/CFG/Chernobyl_run.png b/17-Chernobyl/CFG/Chernobyl_run.png similarity index 100% rename from 17 - Chernobyl/CFG/Chernobyl_run.png rename to 17-Chernobyl/CFG/Chernobyl_run.png diff --git a/17 - Chernobyl/CFG/Chernobyl_run.svg b/17-Chernobyl/CFG/Chernobyl_run.svg similarity index 100% rename from 17 - Chernobyl/CFG/Chernobyl_run.svg rename to 17-Chernobyl/CFG/Chernobyl_run.svg diff --git a/17 - Chernobyl/Code/Makefile b/17-Chernobyl/Code/Makefile similarity index 100% rename from 17 - Chernobyl/Code/Makefile rename to 17-Chernobyl/Code/Makefile diff --git a/17 - Chernobyl/Code/hashbrek.py b/17-Chernobyl/Code/hashbrek.py similarity index 100% rename from 17 - Chernobyl/Code/hashbrek.py rename to 17-Chernobyl/Code/hashbrek.py diff --git a/17 - Chernobyl/Code/inc/chernobyl.h b/17-Chernobyl/Code/inc/chernobyl.h similarity index 83% rename from 17 - Chernobyl/Code/inc/chernobyl.h rename to 17-Chernobyl/Code/inc/chernobyl.h index c14576a..00e159c 100644 --- a/17 - Chernobyl/Code/inc/chernobyl.h +++ b/17-Chernobyl/Code/inc/chernobyl.h @@ -3,7 +3,6 @@ #include "chernobyl_types.h" - u16 _main (); u16 walk (u16 r15); u16 run (); @@ -12,10 +11,12 @@ u16 *create_hash_table (u16 r15, u16 r14); u16 add_to_table (u16 r15, u16 r14, u16 r13); // Return address of a buffer from the table // r15 = buffer address. r14 -u16 get_from_table (void * r15, char * r14); +u16 get_from_table (void *r15, char *r14); u16 hash (char *str); u16 rehash (u16 r15, u16 r14); +// Strings, named after the position of the first character in memory +// Strings associated with #define s_4566 "\r\r" #define s_4569 "%x [alloc] [p %x] [n %x] [s %x]" #define s_4588 " " @@ -23,8 +24,10 @@ u16 rehash (u16 r15, u16 r14); #define s_4594 "%x " #define s_4599 "%x [freed] [p %x] [n %x] [s %x]" +// Strings associated with #define s_465e "Heap exhausted; aborting." +// Strings associated with #define s_4a38 "Welcome to the lock controller." #define s_4a58 "You can open the door by entering 'access [your name] [pin]'" #define s_4a95 "" diff --git a/17 - Chernobyl/Code/inc/chernobyl_stdlib.h b/17-Chernobyl/Code/inc/chernobyl_stdlib.h similarity index 100% rename from 17 - Chernobyl/Code/inc/chernobyl_stdlib.h rename to 17-Chernobyl/Code/inc/chernobyl_stdlib.h diff --git a/17 - Chernobyl/Code/inc/chernobyl_types.h b/17-Chernobyl/Code/inc/chernobyl_types.h similarity index 100% rename from 17 - Chernobyl/Code/inc/chernobyl_types.h rename to 17-Chernobyl/Code/inc/chernobyl_types.h diff --git a/17 - Chernobyl/Code/src/chernobyl.c b/17-Chernobyl/Code/src/chernobyl.c similarity index 100% rename from 17 - Chernobyl/Code/src/chernobyl.c rename to 17-Chernobyl/Code/src/chernobyl.c diff --git a/17 - Chernobyl/Code/src/chernobyl_stdlib.c b/17-Chernobyl/Code/src/chernobyl_stdlib.c similarity index 100% rename from 17 - Chernobyl/Code/src/chernobyl_stdlib.c rename to 17-Chernobyl/Code/src/chernobyl_stdlib.c diff --git a/17-Chernobyl/Emu/Makefile b/17-Chernobyl/Emu/Makefile new file mode 100644 index 0000000..9fc787c --- /dev/null +++ b/17-Chernobyl/Emu/Makefile @@ -0,0 +1,59 @@ + +# ---------- Variables listed below --------- # +# Executable +TARGET := main.out + +# Paths to source, include, dependency, and object files +SPATH = src +IPATH = inc +DPATH = dep +OPATH = obj + +# File type of source file +STYPE = cc + +VPATH = $(SPATH) $(IPATH) $(DPATH) $(OPATH) + +# compiler and compiler flags +CC = g++ +CFLAGS = -I$(IPATH) -std=c++11 -Os + +# list of object files +SOURCES = $(wildcard $(SPATH)/*.$(STYPE)) +OBJECTS = $(addprefix $(OPATH)/,$(notdir $(SOURCES:.$(STYPE)=.o))) + + +# ----------- Targets listed below ---------- # +# Some targets aren't real +.PHONY: all clean run dump +# Don't autodelete object files: +.PRECIOUS: $(OPATH)/%.o + +all: $(DPATH) $(OPATH) $(TARGET) + +dump: + @echo SOURCES: $(SOURCES) + @echo OBJECTS: $(OBJECTS) + @echo TARGET: $(TARGET) + @echo VPATH: $(VPATH) + +clean: + -rm $(TARGET) + -rm -r dep obj + +run: + -$(addprefix ./,$(addsuffix ;,$(TARGET))) + +$(DPATH) $(OPATH): + mkdir -p $@ + +# Make the executable(s) +%.out: $(OBJECTS) + $(CC) $(CFLAGS) -o "$@" $^ +# Make the object and dependency files +$(OPATH)/%.o: $(SPATH)/%.$(STYPE) + $(CC) $(CFLAGS) -MMD -MF "$(DPATH)/$(@F:.o=.d)" -o "$@" -c "$<" + +# --------- Inclusions listed below --------- # +# use dependencies when rebuilding +-include $(wildcard $(DPATH)/*.d) diff --git a/17-Chernobyl/Emu/inc/main.hh b/17-Chernobyl/Emu/inc/main.hh new file mode 100644 index 0000000..85b4085 --- /dev/null +++ b/17-Chernobyl/Emu/inc/main.hh @@ -0,0 +1,6 @@ +#ifndef MAIN_HH_INCLUDED +#define MAIN_HH_INCLUDED + +const int a = 0; + +#endif diff --git a/17-Chernobyl/Emu/src/main.cc b/17-Chernobyl/Emu/src/main.cc new file mode 100644 index 0000000..88ca19a --- /dev/null +++ b/17-Chernobyl/Emu/src/main.cc @@ -0,0 +1,10 @@ + +#include "main.hh" + +#include +#include +#include + +int main (int argc, char *argv[]) { + return 0; +} diff --git a/17 - Chernobyl/Interrupt Listing b/17-Chernobyl/Interrupt Listing similarity index 100% rename from 17 - Chernobyl/Interrupt Listing rename to 17-Chernobyl/Interrupt Listing diff --git a/17 - Chernobyl/instructions.txt b/17-Chernobyl/instructions.txt similarity index 100% rename from 17 - Chernobyl/instructions.txt rename to 17-Chernobyl/instructions.txt diff --git a/17 - Chernobyl/mc-disasm.asm b/17-Chernobyl/mc-disasm.asm similarity index 100% rename from 17 - Chernobyl/mc-disasm.asm rename to 17-Chernobyl/mc-disasm.asm diff --git a/17 - Chernobyl/mc-run.asm b/17-Chernobyl/mc-run.asm similarity index 100% rename from 17 - Chernobyl/mc-run.asm rename to 17-Chernobyl/mc-run.asm diff --git a/17 - Chernobyl/memory.bin b/17-Chernobyl/memory.bin similarity index 100% rename from 17 - Chernobyl/memory.bin rename to 17-Chernobyl/memory.bin