Initial commit.

This commit is contained in:
Denis Drakhnia 2020-11-25 17:18:59 +02:00
commit 89e4166520
9 changed files with 83 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build/

50
Makefile Normal file
View File

@ -0,0 +1,50 @@
PORT := 1234
CHECK := diff -q
MKDIR_P := mkdir -p
CC := lcc
CFLAGS := -nostdlib
QEMU := qemu-e2k
QEMU_ARGS :=
GDB := e2k-linux-gdb
GDB_ARGS := -q --batch --nx --nw -ix gdbinit
GDB_BPS := -ex 'b _start' -ex 'b _stop'
ifndef EMU
GDB_SERVER := gdbserver
GDB_SERVER_ARGS := :$(PORT)
else
GDB_SERVER := $(QEMU)
GDB_SERVER_ARGS := -g $(PORT) $(QEMU_ARGS)
endif
tests := $(subst .s,,$(notdir $(wildcard src/*.s)))
executables := $(addprefix build/,$(tests))
logs := $(addprefix build/,$(addsuffix .log,$(tests)))
checks := $(addprefix check-,$(tests))
.PHONY: all test mkdirs clean $(checks)
all: mkdirs $(logs)
test: mkdirs $(checks)
mkdirs:
$(MKDIR_P) build
clean:
$(RM) $(executables)
$(RM) $(logs)
$(executables): build/%: src/%.s
$(CC) $(CFLAGS) -o $@ $<
$(logs): build/%.log: build/% src/%.gdb
$(GDB_SERVER) $(GDB_SERVER_ARGS) $< &
$(GDB) $(GDB_ARGS) -ex 'file $<' $(GDB_BPS) \
-ex 'target remote :$(PORT)' -x src/$*.gdb > $@
$(checks): check-%: build/%.log src/%.log
$(CHECK) $^

2
gdbinit Normal file
View File

@ -0,0 +1,2 @@
set pagination off
set confirm off

2
src/addd.gdb Normal file
View File

@ -0,0 +1,2 @@
c
info registers r0

6
src/addd.log Normal file
View File

@ -0,0 +1,6 @@
Breakpoint 1 at 0x10078
Breakpoint 2 at 0x10080
0x0000000000010078 in _start ()
Breakpoint 2, 0x0000000000010080 in _stop ()
r0 <00> 0x4 4

7
src/addd.s Normal file
View File

@ -0,0 +1,7 @@
.global _start
.global _stop
_start:
addd 2, 2, %r0
_stop:
udivs 0, 0, %empty

2
src/subd.gdb Normal file
View File

@ -0,0 +1,2 @@
c
info registers r0

6
src/subd.log Normal file
View File

@ -0,0 +1,6 @@
Breakpoint 1 at 0x10078
Breakpoint 2 at 0x10080
0x0000000000010078 in _start ()
Breakpoint 2, 0x0000000000010080 in _stop ()
r0 <00> 0x0 0

7
src/subd.s Normal file
View File

@ -0,0 +1,7 @@
.global _start
.global _stop
_start:
subd 2, 2, %r0
_stop:
udivs 0, 0, %empty