This commit is contained in:
mpabi 2025-02-27 12:41:11 +00:00
parent cfe877a4ec
commit 40c061cf4c
3 changed files with 101 additions and 3 deletions

View File

@ -1,15 +1,20 @@
.data
sentence: .ascii "Become a Prograammer"
// 0x8000102c
sentence: .ascii "Become a Prograammermmmmmrr\0"
// ^
// ^
.text
.align 2
.globl _start
_start:
la t2, sentence # Load the address of sentence into t2
li t0, 0x6d // ascii 'm'
li t1, 0 // licznik wystapien 'm'
li t0, 0x72 // ascii 'm'
li t1, 0x00 // licznik wystapien 'm'
print_loop:
lbu t3, 0(t2) # Load the byte (character) from address in t2

81
make/Make.rules Normal file
View File

@ -0,0 +1,81 @@
ARCH=riscv32-unknown-elf
GNU_DIR=$(HOME)/riscv/opt/rv32im_zicsr/
GNU_BIN=$(GNU_DIR)/bin
CC=$(GNU_BIN)/$(ARCH)-gcc
CXX=$(GNU_BIN)/$(ARCH)-g++
AS=$(GNU_BIN)/$(ARCH)-as
LD=$(GNU_BIN)/$(ARCH)-ld
OBJCOPY=$(GNU_BIN)/$(ARCH)-objcopy
OBJDUMP=$(GNU_BIN)/$(ARCH)-objdump
SIZE=$(GNU_BIN)/$(ARCH)-size
AR=$(GNU_BIN)/$(ARCH)-ar
RANLIB=$(GNU_BIN)/$(ARCH)-ranlib
CFLAGS+=-ffreestanding
CFLAGS+=-fno-pic
CFLAGS+=-march=rv32i -mabi=ilp32
CFLAGS+= -O0 -g
LDFLAGS+=-nostdlib
LDFLAGS+=-Wl,-Ttext=0x80000000
LDFLAGS+= -g
# see: https://github.com/riscv/riscv-gcc/issues/120
#LDFLAGS+=-Wl,--no-relax
ASFLAGS+=$(CFLAGS)
CXXFLAGS+=$(CFLAGS)
CLEAN_DIRS=$(SUBDIRS:%=clean-%)
ALL_DIRS=$(SUBDIRS:%=all-%)
OBJDUMPFLAGS+=-Mnumeric,no-aliases
.PHONY: all clean world $(CLEAN_DIRS) $(ALL_DIRS)
%.bin : %
$(OBJCOPY) $< -O binary $@
%.lst : %
$(OBJDUMP) $(OBJDUMPFLAGS) -dr $< > $<.lst
% : %.o
$(LINK.c) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(SIZE) -x -A $@
%.s: %.c
$(COMPILE.c) -S -o $@ $<
%.s: %.cc
$(COMPILE.cc) -S -o $@ $<
%.o: %.c
$(COMPILE.c) -o $@ $<
%.o: %.cc
$(COMPILE.cc) -o $@ $<
%.srec: %
$(OBJCOPY) $< -O srec $@
all:: $(ALL_DIRS)
clean:: $(CLEAN_DIRS)
$(ALL_DIRS)::
$(MAKE) -C $(@:all-%=%) all
$(CLEAN_DIRS)::
$(MAKE) -C $(@:clean-%=%) clean
world:: clean all

12
make/Makefile Normal file
View File

@ -0,0 +1,12 @@
SUBDIRS=\
load4regs \
counter \
padd \
link \
uart \
sw \
freestanding
TOP=.
include $(TOP)/Make.rules