Skip to content
Snippets Groups Projects
Commit d4430035 authored by Pavel Pisa's avatar Pavel Pisa
Browse files

seminaries/qtrvsim/qtrvsim-semstart: copy from QtRVSim


Signed-off-by: default avatarPavel Pisa <pisa@cmp.felk.cvut.cz>
parent ba7bcaad
Branches master
No related tags found
No related merge requests found
*.o
depend
simple-lw-sw
ARCH=riscv64-unknown-elf
SOURCES = simple-lw-sw.S
TARGET_EXE = simple-lw-sw
LDFLAGS += -Wl,-Ttext,0x200 -Wl,-Tdata,0x400
CC=$(ARCH)-gcc
CXX=$(ARCH)-g++
AS=$(ARCH)-as
LD=$(ARCH)-ld
OBJCOPY=$(ARCH)-objcopy
ARCHFLAGS += -mabi=ilp32
ARCHFLAGS += -march=rv32i
ARCHFLAGS += -fno-lto
CFLAGS += -ggdb -Os -Wall
CXXFLAGS+= -ggdb -Os -Wall
AFLAGS += -ggdb
LDFLAGS += -ggdb
LDFLAGS += -nostartfiles
LDFLAGS += -nostdlib
LDFLAGS += -static
#LDFLAGS += -specs=/opt/musl/riscv64-linux-gnu/lib/musl-gcc.specs
CFLAGS += $(ARCHFLAGS)
CXXFLAGS+= $(ARCHFLAGS)
AFLAGS += $(ARCHFLAGS)
LDFLAGS += $(ARCHFLAGS)
OBJECTS += $(filter %.o,$(SOURCES:%.S=%.o))
OBJECTS += $(filter %.o,$(SOURCES:%.c=%.o))
OBJECTS += $(filter %.o,$(SOURCES:%.cpp=%.o))
all : default
.PHONY : default clean dep all
%.o:%.S
$(CC) -D__ASSEMBLY__ $(AFLAGS) -c $< -o $@
%.o:%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
%.o:%.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
%.s:%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -S $< -o $@
default : $(TARGET_EXE)
$(TARGET_EXE) : $(OBJECTS)
$(CC) $(LDFLAGS) $^ -o $@
dep: depend
depend: $(SOURCES) $(glob *.h)
echo '# autogenerated dependencies' > depend
ifneq ($(filter %.S,$(SOURCES)),)
$(CC) -D__ASSEMBLY__ $(AFLAGS) -w -E -M $(filter %.S,$(SOURCES)) \
>> depend
endif
ifneq ($(filter %.c,$(SOURCES)),)
$(CC) $(CFLAGS) $(CPPFLAGS) -w -E -M $(filter %.c,$(SOURCES)) \
>> depend
endif
ifneq ($(filter %.cpp,$(SOURCES)),)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -w -E -M $(filter %.cpp,$(SOURCES)) \
>> depend
endif
clean:
rm -f *.o *.a $(OBJECTS) $(TARGET_EXE) depend
#mips-elf-objdump --source -M no-aliases,reg-names=numeric qtmips_binrep
-include depend
// Template file with simple memory example
// QtRVSim simulator https://github.com/cvut/qtrvsim/
//
// template-os.S - example file
//
// (C) 2021 by Pavel Pisa
// e-mail: pisa@cmp.felk.cvut.cz
// homepage: http://cmp.felk.cvut.cz/~pisa
// work: http://www.pikron.com/
// license: public domain
// Directives to make interesting windows visible
#pragma qtrvsim show registers
#pragma qtrvsim show memory
.globl _start
.option norelax
.text
_start:
loop:
// load the word from absolute address
lw x2, 0x400(x0)
// store the word to absolute address
sw x2, 0x404(x0)
// stop execution wait for debugger/user
// ebreak
// ensure that continuation does not
// interpret random data
beq x0, x0, loop
nop
nop
ebreak
.data
.org 0x400
src_val:
.word 0x12345678
dst_val:
.word 0
// Specify location to show in memory window
#pragma qtrvsim focus memory src_val
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment