.clang_complete
# .clangd
.session
+
+ulas
+testulas
+++ /dev/null
-.\" Manpage for ulas.
-.\" Contact lukas@krickl.dev to correct errors or typos.
-
-.TH man 1 "21 August 2023" "0.0.1" "ulas manual"
-
-.SH NAME
- ulas
-.SH SYNOPSIS
- ulas [-hvV]
-.SH DESCRIPTION
- ulas
-
- -h
- display this help and exit
- -v
- display version info and exit
- -v, --verbose
- verbose output
-
-.SH PREPROCESSOR
-
-The preprocessor is a text based way of modifying the input before
-the assembly step. Stray tokens after a directive are ignored!
-
-Preprocessor directives start with a # and have to be the first non-space character in a line.
-All lines that are not a preprocessor directive, or are not part of a preprocessor block (macro, or if)
-will be output as-is. If a line contains the name of a preprocessot define or macro
-,surrounded by token any character that is not alphanumeric or an underscore,
-the define or macro will be expanded.
-
-Withing preprocessor macros
-- $0 will expand to the literal argument string
-- $1 to $9 will expand to the comma separated arguments of the macro
-- $$ will insert a unique numeric literal
-
-Macros:
-
-#macro my_macro
-label$$:
- adc $1, $2
-#endmacro
-
-my_macro a, b
-
-Define:
-
-#define name value
-name ; will be replaced with 'value'
-#undefine name
-
-.SH ASSEMBLY SYNTAX
-
-
-
-.SH EXPRESSION SYNTAX
-
-Expressions are written in Reverse Polish Notation style and evaluated based on their expected data type.
-For example when an expression expects an int type the expression will assume all values that are pushed to it
-are integers.
-
-.SH ASSEMBLY DIRECTIVES
-
-During assembly sometimes it is required to set certain parameters of the assembler such as the base address (represented by the $@ symbol in expressions).
-
-Valid directives:
-
- \.org <expression>
- Sets the base address
-
-.SH EXAMPLES
-
-.SH SEE ALSO
-
-.SH BUGS
-
-.SH AUTHOR
- Lukas Krickl (lukas@krickl.dev)
-
-.SH COPYRIGHT
- Copyright 2023 Lukas Krickl (lukas@krickl.dev)
NAME=ulas
-IDIR=./src
-SDIR=./src
-CC=gcc
+TEST_NAME=test$(NAME)
DBGCFLAGS=-g -fsanitize=address
DBGLDFLAGS=-fsanitize=address
-CFLAGS=-I$(IDIR) -Wall -pedantic $(DBGCFLAGS) -std=gnu99
+CFLAGS=-Wall -pedantic $(DBGCFLAGS) -std=gnu99
LIBS=
-TEST_LIBS=
LDFLAGS=$(DBGLDFLAGS) $(LIBS)
-TAG_LIBS=/usr/include/unistd.h /usr/include/stdio.h /usr/include/stdlib.h /usr/include/assert.h /usr/include/errno.h /usr/include/ctype.h
+INSTALL_DIR=/usr/local
+OBJS:=ulas.o archs.o uldas.o
-ODIR=obj
-TEST_ODIR=obj/test
-BDIR=bin
-BNAME=$(NAME)
-MAIN=main.o
-TEST_MAIN=test.o
-TEST_BNAME=testulas
-
-BIN_INSTALL_DIR=/usr/local/bin
-MAN_INSTALL_DIR=/usr/local/man
-
-OBJ = $(ODIR)/$(MAIN) $(ODIR)/ulas.o $(ODIR)/archs.o $(ODIR)/uldas.o
+CCOBJ=$(CC) -c -o $@ $< $(CFLAGS) $(LDFLAGS)
all: bin test
release:
make DBGCFLAGS="" DBGLDFLAGS=""
-$(ODIR)/%.o: src/%.c src/*.h
- mkdir -p $(@D)
- $(CC) -c -o $@ $< $(CFLAGS) $(LDFLAGS)
-bin: $(OBJ)
- mkdir -p $(BDIR)
- $(CC) -o $(BDIR)/$(BNAME) $^ $(CFLAGS) $(LDFLAGS)
+main.o: src/main.c
+ $(CCOBJ)
+test.o: src/test.c
+ $(CCOBJ)
+ulas.o: src/ulas.c
+ $(CCOBJ)
+uldas.o: src/uldas.c
+ $(CCOBJ)
+archs.o: src/archs.c
+ $(CCOBJ)
+
-test:
- echo "building tests"
- make bin MAIN=$(TEST_MAIN) BNAME=$(TEST_BNAME) ODIR=$(TEST_ODIR) LIBS=$(TEST_LIBS)
+bin: main.o $(OBJS)
+ $(CC) -o $(NAME) main.o $(OBJS) $(CFLAGS) $(LDFLAGS)
-.PHONY: clean
+test: test.o $(OBJS)
+ $(CC) -o $(TEST_NAME) test.o $(OBJS) $(CFLAGS) $(LDFLAGS)
+.PHONY: clean
clean:
- rm -f ./$(ODIR)/*.o
- rm -f ./$(TEST_ODIR)/*.o
- rm -f ./$(BDIR)/$(BNAME)
- rm -f ./$(BDIR)/$(TEST_BNAME)
+ rm -f ./*.o
+ rm -f ./$(NAME)
+ rm -f ./$(TEST_NAME)
.PHONY: install
-
install:
- cp ./$(BDIR)/$(BNAME) $(BIN_INSTALL_DIR)
- cp ./doc/$(BNAME).1 $(MAN_INSTALL_DIR)
+ cp ./$(NAME) $(INSTALL_DIR)/bin
+ cp ./man/$(NAME).1 $(INSTALL_DIR)/man
.PHONY: tags
tags:
- ctags --recurse=yes --exclude=.git --exclude=bin --exclude=obj --extras=* --fields=* --c-kinds=* --language-force=C $(TAG_LIBS) .
+ ctags --recurse=yes --exclude=.git --exclude=bin --exclude=obj --extras=* --fields=* --c-kinds=* --language-force=C .
-.PHONY:
+.PHONY: ccmds
ccmds:
bear -- make SHELL="sh -x -e" --always-make
.PHONY: format
format:
- clang-format -i ./src/*.c ./src/*.h
+ clang-format -i src/*.c src/*.h
.PHONY: lint
lint:
- clang-tidy ./src/*.h ./src/*.c
+ clang-tidy src/*.h src/*.c
-buildtests:
- ./$(BDIR)/$(BNAME) tests/t0.s -l - -o tests/t0.bin
- ./$(BDIR)/$(BNAME) tests/t0.bin -d - -o tests/t0_dasm.s
+buildtests: $(NAME)
+ ./$(NAME) tests/t0.s -l - -o tests/t0.bin
+ ./$(NAME) tests/t0.bin -d - -o tests/t0_dasm.s
--- /dev/null
+.\" Manpage for ulas.
+.\" Contact lukas@krickl.dev to correct errors or typos.
+
+.TH man 1 "21 August 2023" "0.0.1" "ulas manual"
+
+.SH NAME
+ ulas
+.SH SYNOPSIS
+ ulas [-hvV]
+.SH DESCRIPTION
+ ulas
+
+ -h
+ display this help and exit
+ -v
+ display version info and exit
+ -v, --verbose
+ verbose output
+
+.SH PREPROCESSOR
+
+The preprocessor is a text based way of modifying the input before
+the assembly step. Stray tokens after a directive are ignored!
+
+Preprocessor directives start with a # and have to be the first non-space character in a line.
+All lines that are not a preprocessor directive, or are not part of a preprocessor block (macro, or if)
+will be output as-is. If a line contains the name of a preprocessot define or macro
+,surrounded by token any character that is not alphanumeric or an underscore,
+the define or macro will be expanded.
+
+Withing preprocessor macros
+- $0 will expand to the literal argument string
+- $1 to $9 will expand to the comma separated arguments of the macro
+- $$ will insert a unique numeric literal
+
+Macros:
+
+#macro my_macro
+label$$:
+ adc $1, $2
+#endmacro
+
+my_macro a, b
+
+Define:
+
+#define name value
+name ; will be replaced with 'value'
+#undefine name
+
+.SH ASSEMBLY SYNTAX
+
+
+
+.SH EXPRESSION SYNTAX
+
+Expressions are written in Reverse Polish Notation style and evaluated based on their expected data type.
+For example when an expression expects an int type the expression will assume all values that are pushed to it
+are integers.
+
+.SH ASSEMBLY DIRECTIVES
+
+During assembly sometimes it is required to set certain parameters of the assembler such as the base address (represented by the $@ symbol in expressions).
+
+Valid directives:
+
+ \.org <expression>
+ Sets the base address
+
+.SH EXAMPLES
+
+.SH SEE ALSO
+
+.SH BUGS
+
+.SH AUTHOR
+ Lukas Krickl (lukas@krickl.dev)
+
+.SH COPYRIGHT
+ Copyright 2023 Lukas Krickl (lukas@krickl.dev)