Skip to content

Commit

Permalink
Updated microcode assembler to use flat file structure and compile on…
Browse files Browse the repository at this point in the history
… Linux.
  • Loading branch information
linguini1 committed Jan 9, 2024
1 parent b6a63f9 commit 90f9171
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
3 changes: 1 addition & 2 deletions assembler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ assembler: $(OBJ_FILES)
tester:
$(CC) $(CFLAGS) tests/test.c -o $(TEST_OUT)

%.o: %.c
$(CC) $(CFLAGS) $(WARNINGS) -o $@ -c $<
%.o: %.c $(CC) $(CFLAGS) $(WARNINGS) -o $@ -c $<

check: assembler tester
@echo "RUNNING TESTS"
Expand Down
8 changes: 5 additions & 3 deletions schematic/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
compile_commands.json
# Output
mcasm.exe
/obj/
*.o
/.cache/

# Debug/development
compile_commands.json
.cache/
38 changes: 28 additions & 10 deletions schematic/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
CC = gcc
CFLAGS = -O3 -Wall
OUT = mcasm
OBJ_DIR = ./obj
OBJ_FILES = $(OBJ_DIR)/*.o

all:
if [ ! -d $(OBJ_DIR) ]; then mkdir $(OBJ_DIR); fi
$(CC) $(CFLAGS) -c src/hashmap.c -o $(OBJ_DIR)/hashmap.o
$(CC) $(CFLAGS) -c src/lexer.c -o $(OBJ_DIR)/lexer.o
$(CC) $(CFLAGS) -c mcasm.c -o $(OBJ_DIR)/mcasm.o
### SOURCE FILES ###
SRCDIR = src
SRC_FILES = $(wildcard $(SRCDIR)/*.c)
OBJ_FILES = $(patsubst %.c,%.o,$(SRC_FILES))

### WARNINGS ###
# (see https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Warning-Options.html)
WARNINGS += -Wall -Wextra -Wshadow -Wundef -Wformat=2 -Wtrampolines -Wfloat-equal
WARNINGS += -Wbad-function-cast -Wstrict-prototypes -Wpacked
WARNINGS += -Wno-aggressive-loop-optimizations -Wmissing-prototypes -Winit-self
WARNINGS += -Wmissing-declarations -Wmissing-format-attribute -Wunreachable-code
WARNINGS += -Wshift-overflow=2 -Wduplicated-cond -Wpointer-arith -Wwrite-strings
WARNINGS += -Wnested-externs -Wcast-align -Wredundant-decls
WARNINGS += -Werror=implicit-function-declaration -Wlogical-not-parentheses
WARNINGS += -Wlogical-op -Wold-style-definition -Wcast-qual -Wdouble-promotion
WARNINGS += -Wunsuffixed-float-constants -Wmissing-include-dirs -Wnormalized
WARNINGS += -Wdisabled-optimization -Wsuggest-attribute=const

### COMPILER OPTIONS ###
CFLAGS += -O3
CFLAGS += -lm

all: $(OBJ_FILES)
$(CC) $(CFLAGS) $(OBJ_FILES) -o $(OUT)

%.o: %.c
$(CC) $(CFLAGS) $(WARNINGS) -o $@ -c $<

clean:
rm -r $(OBJ_DIR)
rm $(OUT)
@rm $(OBJ_FILES)
@rm $(OUT)
4 changes: 2 additions & 2 deletions schematic/mcasm.c → schematic/src/mcasm.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Tool for assembling micro code into binary from a gol-16 microcode file */
#include "src/hashmap.h"
#include "src/lexer.h"
#include "hashmap.h"
#include "lexer.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
Expand Down

0 comments on commit 90f9171

Please sign in to comment.