first commit
This commit is contained in:
commit
05e0c12594
9 changed files with 70 additions and 0 deletions
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[submodule "libqbe"]
|
||||||
|
path = libqbe
|
||||||
|
url = https://git.samahh.dev/sam/libqbe
|
||||||
|
[submodule "slibs"]
|
||||||
|
path = slibs
|
||||||
|
url = https://git.samahh.dev/sam/slibs
|
19
.vscode/c_cpp_properties.json
vendored
Normal file
19
.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Mac",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"macFrameworkPath": [
|
||||||
|
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
|
||||||
|
],
|
||||||
|
"compilerPath": "/usr/bin/clang",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"intelliSenseMode": "macos-clang-arm64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
23
Makefile
Normal file
23
Makefile
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
BINARY=test
|
||||||
|
|
||||||
|
CC=gcc
|
||||||
|
CFLAGS=-I.
|
||||||
|
LDFLAGS=-Llibqbe -lqbe
|
||||||
|
|
||||||
|
CFILES=$(shell find -L src -type f -name '*.c')
|
||||||
|
OBJ=$(CFILES:.c=.o)
|
||||||
|
|
||||||
|
$(BINARY): libqbe/libqbe.a $(OBJ) Makefile
|
||||||
|
$(CC) $(OBJ) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
run: $(BINARY)
|
||||||
|
./$(BINARY)
|
||||||
|
|
||||||
|
libqbe/libqbe.a:
|
||||||
|
make -C libqbe
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(OBJ) $(BINARY)
|
12
file.ssa
Normal file
12
file.ssa
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
function w $add(w %a, w %b) { # Define a function add
|
||||||
|
@start
|
||||||
|
%c =w add %a, %b # Adds the 2 arguments
|
||||||
|
ret %c # Return the result
|
||||||
|
}
|
||||||
|
export function w $main() { # Main function
|
||||||
|
@start
|
||||||
|
%r =w call $add(w 1, w 1) # Call add(1, 1)
|
||||||
|
call $printf(l $fmt, ..., w %r) # Show the result
|
||||||
|
ret 0
|
||||||
|
}
|
||||||
|
data $fmt = { b "One and one make %d!\n", b 0 }
|
1
libqbe
Submodule
1
libqbe
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit e15499786214d7cd7f9a6151f99ea660c9b498bd
|
1
slibs
Submodule
1
slibs
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 986006449d1586d9ae55e5696015aa67b0e33f4f
|
8
src/main.c
Normal file
8
src/main.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <libqbe/libqbe.h>
|
||||||
|
#define SL_IMPLEMENTATION
|
||||||
|
#include <slibs/slibs.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
printf("%s\n^ output\n", qbe_emit(Deftgt, sl_c_str(*sl_read_file("file.ssa"))));
|
||||||
|
}
|
BIN
src/main.o
Normal file
BIN
src/main.o
Normal file
Binary file not shown.
BIN
test
Executable file
BIN
test
Executable file
Binary file not shown.
Loading…
Add table
Reference in a new issue