Moved C and ASM code to tests folder
This commit is contained in:
parent
2a56493fc4
commit
d405857f25
|
@ -0,0 +1,52 @@
|
|||
TARGET = forloop
|
||||
|
||||
TARGET_ARCH=riscv32
|
||||
|
||||
CC = riscv32-unknown-linux-gnu-gcc
|
||||
# compiling flags here
|
||||
#CFLAGS = -Wall -I. -O0 -nostartfiles -march=rv32i -mabi=ilp32
|
||||
CFLAGS = -Wall -I. -O0 -nostdlib -march=rv32i -mabi=ilp32 --entry main
|
||||
#CFLAGS = -Wall -I. -O0 -nodefaultlibs -march=rv32i -mabi=ilp32
|
||||
|
||||
|
||||
LINKER = riscv32-unknown-linux-gnu-gcc
|
||||
# linking flags here
|
||||
LFLAGS = -I. --entry main
|
||||
LIBS = $(EXTRA_LIBS)
|
||||
|
||||
|
||||
# change these to proper directories where each file should be
|
||||
SRCDIR = ./
|
||||
OBJDIR = .
|
||||
BINDIR = ./
|
||||
INCDIR = -I.
|
||||
LIBDIR = -L.
|
||||
|
||||
|
||||
SOURCES := $(wildcard $(SRCDIR)/*.c)
|
||||
INCLUDES := $(wildcard $(INCDIR)/*.h)
|
||||
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
|
||||
rm = rm -f
|
||||
|
||||
|
||||
$(BINDIR)/$(TARGET): $(OBJECTS)
|
||||
# $(LINKER) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
|
||||
riscv32-unknown-linux-gnu-objdump -d $< > dump
|
||||
objcopy -Oihex $< $(TARGET).hex
|
||||
# @echo "Linking complete!"
|
||||
|
||||
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
|
||||
@echo "Compiling "$<" ..."
|
||||
# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(INCDIR) $< -o $@
|
||||
@echo "Done!"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(rm) $(OBJECTS)
|
||||
@echo "Cleanup complete!"
|
||||
|
||||
.PHONY: remove
|
||||
remove: clean
|
||||
@$(rm) $(BINDIR)/$(TARGET)
|
||||
@echo "Executable removed!"
|
|
@ -0,0 +1,8 @@
|
|||
void main(void) {
|
||||
volatile int i;
|
||||
volatile int a;
|
||||
|
||||
for(i=0;i<10;i++) {
|
||||
a=i+5;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
TARGET = func1
|
||||
|
||||
TARGET_ARCH=riscv32
|
||||
|
||||
CC = riscv32-unknown-linux-gnu-gcc
|
||||
# compiling flags here
|
||||
#CFLAGS = -Wall -I. -O0 -nostartfiles -march=rv32i -mabi=ilp32
|
||||
CFLAGS = -Wall -I. -O0 -nostdlib -march=rv32i -mabi=ilp32 --entry main
|
||||
#CFLAGS = -Wall -I. -O0 -nodefaultlibs -march=rv32i -mabi=ilp32
|
||||
|
||||
|
||||
LINKER = riscv32-unknown-linux-gnu-gcc
|
||||
# linking flags here
|
||||
LFLAGS = -I. --entry main
|
||||
LIBS = $(EXTRA_LIBS)
|
||||
|
||||
|
||||
# change these to proper directories where each file should be
|
||||
SRCDIR = ./
|
||||
OBJDIR = .
|
||||
BINDIR = ./
|
||||
INCDIR = -I.
|
||||
LIBDIR = -L.
|
||||
|
||||
|
||||
SOURCES := $(wildcard $(SRCDIR)/*.c)
|
||||
INCLUDES := $(wildcard $(INCDIR)/*.h)
|
||||
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
|
||||
rm = rm -f
|
||||
|
||||
|
||||
$(BINDIR)/$(TARGET): $(OBJECTS)
|
||||
# $(LINKER) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
|
||||
riscv32-unknown-linux-gnu-objdump -d $< > dump
|
||||
objcopy -Oihex $< $(TARGET).hex
|
||||
# @echo "Linking complete!"
|
||||
|
||||
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
|
||||
@echo "Compiling "$<" ..."
|
||||
# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(INCDIR) $< -o $@
|
||||
@echo "Done!"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(rm) $(OBJECTS)
|
||||
@echo "Cleanup complete!"
|
||||
|
||||
.PHONY: remove
|
||||
remove: clean
|
||||
@$(rm) $(BINDIR)/$(TARGET)
|
||||
@echo "Executable removed!"
|
|
@ -0,0 +1,25 @@
|
|||
#define TRACE (*(unsigned char *)0x40000000)
|
||||
|
||||
int func1(int a, int* b) {
|
||||
return a + (*b);
|
||||
}
|
||||
|
||||
|
||||
void main(void) {
|
||||
int x1, x2, x3;
|
||||
|
||||
x1 = 6;
|
||||
x2 = 7;
|
||||
|
||||
x3 = func1(x1, &x2);
|
||||
|
||||
if (x3 == 13) {
|
||||
TRACE = 'O';
|
||||
TRACE = 'K';
|
||||
TRACE = '\n';
|
||||
} else {
|
||||
TRACE = 'E';
|
||||
TRACE = 'R';
|
||||
TRACE = '\n';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
TARGET = func2
|
||||
|
||||
TARGET_ARCH=riscv32
|
||||
|
||||
CC = riscv32-unknown-linux-gnu-gcc
|
||||
# compiling flags here
|
||||
#CFLAGS = -Wall -I. -O0 -nostartfiles -march=rv32i -mabi=ilp32
|
||||
CFLAGS = -Wall -I. -O0 -nostdlib -march=rv32i -mabi=ilp32 --entry main
|
||||
#CFLAGS = -Wall -I. -O0 -nodefaultlibs -march=rv32i -mabi=ilp32
|
||||
|
||||
|
||||
LINKER = riscv32-unknown-linux-gnu-gcc
|
||||
# linking flags here
|
||||
LFLAGS = -I. --entry main
|
||||
LIBS = $(EXTRA_LIBS)
|
||||
|
||||
|
||||
# change these to proper directories where each file should be
|
||||
SRCDIR = ./
|
||||
OBJDIR = .
|
||||
BINDIR = ./
|
||||
INCDIR = -I.
|
||||
LIBDIR = -L.
|
||||
|
||||
|
||||
SOURCES := $(wildcard $(SRCDIR)/*.c)
|
||||
INCLUDES := $(wildcard $(INCDIR)/*.h)
|
||||
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
|
||||
rm = rm -f
|
||||
|
||||
|
||||
$(BINDIR)/$(TARGET): $(OBJECTS)
|
||||
# $(LINKER) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
|
||||
riscv32-unknown-linux-gnu-objdump -d $< > dump
|
||||
objcopy -Oihex $< $(TARGET).hex
|
||||
# @echo "Linking complete!"
|
||||
|
||||
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
|
||||
@echo "Compiling "$<" ..."
|
||||
# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(INCDIR) $< -o $@
|
||||
@echo "Done!"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(rm) $(OBJECTS)
|
||||
@echo "Cleanup complete!"
|
||||
|
||||
.PHONY: remove
|
||||
remove: clean
|
||||
@$(rm) $(BINDIR)/$(TARGET)
|
||||
@echo "Executable removed!"
|
|
@ -0,0 +1,29 @@
|
|||
#define TRACE (*(unsigned char *)0x40000000)
|
||||
|
||||
void print(char *msg) {
|
||||
int i = 0;
|
||||
while(msg[i] != '\0') {
|
||||
TRACE = msg[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
int func1(int a, int* b) {
|
||||
return a + (*b);
|
||||
}
|
||||
|
||||
|
||||
void main(void) {
|
||||
int x1, x2, x3;
|
||||
|
||||
x1 = 6;
|
||||
x2 = 7;
|
||||
|
||||
x3 = func1(x1, &x2);
|
||||
|
||||
if (x3 == 13) {
|
||||
print("OK\n");
|
||||
} else {
|
||||
print("ERROR\n");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
TARGET = stdlibs
|
||||
|
||||
TARGET_ARCH=riscv32
|
||||
|
||||
CC = riscv32-unknown-linux-gnu-gcc
|
||||
# compiling flags here
|
||||
#CFLAGS = -Wall -I. -O0 -march=rv32 -mabi=ilp32
|
||||
#CFLAGS = -Wall -I. -O0 -nostdlib -march=rv32i -mabi=ilp32 --entry main -lc
|
||||
CFLAGS = -Wall -I. -O0 -nostdlib -march=rv32i -mabi=ilp32 --entry main
|
||||
|
||||
|
||||
LINKER = riscv32-unknown-linux-gnu-gcc
|
||||
# linking flags here
|
||||
LFLAGS = -I.
|
||||
LIBS = $(EXTRA_LIBS)
|
||||
|
||||
|
||||
# change these to proper directories where each file should be
|
||||
SRCDIR = ./
|
||||
OBJDIR = .
|
||||
BINDIR = ./
|
||||
INCDIR = -I.
|
||||
LIBDIR = -L.
|
||||
|
||||
|
||||
SOURCES := $(wildcard $(SRCDIR)/*.c)
|
||||
INCLUDES := $(wildcard $(INCDIR)/*.h)
|
||||
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
|
||||
rm = rm -f
|
||||
|
||||
|
||||
$(BINDIR)/$(TARGET): $(OBJECTS)
|
||||
# $(LINKER) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
|
||||
riscv32-unknown-linux-gnu-objdump -d $< > dump
|
||||
objcopy -Oihex $< $(TARGET).hex
|
||||
# @echo "Linking complete!"
|
||||
|
||||
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
|
||||
@echo "Compiling "$<" ..."
|
||||
# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(INCDIR) $< -o $@
|
||||
@echo "Done!"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(rm) $(OBJECTS)
|
||||
@echo "Cleanup complete!"
|
||||
|
||||
.PHONY: remove
|
||||
remove: clean
|
||||
@$(rm) $(BINDIR)/$(TARGET)
|
||||
@echo "Executable removed!"
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define TRACE (*(unsigned char *)0x40000000)
|
||||
|
||||
void print(char *msg) {
|
||||
int i = 0;
|
||||
while(msg[i] != '\0') {
|
||||
TRACE = msg[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
char msg[50];
|
||||
print("hello");
|
||||
sprintf(msg, "%i", 5);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
TARGET = trace
|
||||
|
||||
TARGET_ARCH=riscv32
|
||||
|
||||
CC = riscv32-unknown-linux-gnu-gcc
|
||||
# compiling flags here
|
||||
#CFLAGS = -Wall -I. -O0 -nostartfiles -march=rv32i -mabi=ilp32
|
||||
CFLAGS = -Wall -I. -O0 -nostdlib -march=rv32i -mabi=ilp32 --entry main
|
||||
#CFLAGS = -Wall -I. -O0 -nodefaultlibs -march=rv32i -mabi=ilp32
|
||||
|
||||
|
||||
LINKER = riscv32-unknown-linux-gnu-gcc
|
||||
# linking flags here
|
||||
LFLAGS = -I. --entry main
|
||||
LIBS = $(EXTRA_LIBS)
|
||||
|
||||
|
||||
# change these to proper directories where each file should be
|
||||
SRCDIR = ./
|
||||
OBJDIR = .
|
||||
BINDIR = ./
|
||||
INCDIR = -I.
|
||||
LIBDIR = -L.
|
||||
|
||||
|
||||
SOURCES := $(wildcard $(SRCDIR)/*.c)
|
||||
INCLUDES := $(wildcard $(INCDIR)/*.h)
|
||||
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
|
||||
rm = rm -f
|
||||
|
||||
|
||||
$(BINDIR)/$(TARGET): $(OBJECTS)
|
||||
# $(LINKER) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
|
||||
riscv32-unknown-linux-gnu-objdump -d $< > dump
|
||||
objcopy -Oihex $< $(TARGET).hex
|
||||
# @echo "Linking complete!"
|
||||
|
||||
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
|
||||
@echo "Compiling "$<" ..."
|
||||
# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(INCDIR) $< -o $@
|
||||
@echo "Done!"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(rm) $(OBJECTS)
|
||||
@echo "Cleanup complete!"
|
||||
|
||||
.PHONY: remove
|
||||
remove: clean
|
||||
@$(rm) $(BINDIR)/$(TARGET)
|
||||
@echo "Executable removed!"
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
#define TRACE (*(unsigned char *)0x40000000)
|
||||
|
||||
void main(void) {
|
||||
TRACE = 'H';
|
||||
TRACE = 'e';
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
TARGET = trace2
|
||||
|
||||
TARGET_ARCH=riscv32
|
||||
|
||||
CC = riscv32-unknown-linux-gnu-gcc
|
||||
# compiling flags here
|
||||
#CFLAGS = -Wall -I. -O0 -nostartfiles -march=rv32i -mabi=ilp32
|
||||
CFLAGS = -Wall -I. -O0 -nostdlib -march=rv32i -mabi=ilp32 --entry main
|
||||
#CFLAGS = -Wall -I. -O0 -nodefaultlibs -march=rv32i -mabi=ilp32
|
||||
|
||||
|
||||
LINKER = riscv32-unknown-linux-gnu-gcc
|
||||
# linking flags here
|
||||
LFLAGS = -I. --entry main
|
||||
LIBS = $(EXTRA_LIBS)
|
||||
|
||||
|
||||
# change these to proper directories where each file should be
|
||||
SRCDIR = ./
|
||||
OBJDIR = .
|
||||
BINDIR = ./
|
||||
INCDIR = -I.
|
||||
LIBDIR = -L.
|
||||
|
||||
|
||||
SOURCES := $(wildcard $(SRCDIR)/*.c)
|
||||
INCLUDES := $(wildcard $(INCDIR)/*.h)
|
||||
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
|
||||
rm = rm -f
|
||||
|
||||
|
||||
$(BINDIR)/$(TARGET): $(OBJECTS)
|
||||
# $(LINKER) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
|
||||
riscv32-unknown-linux-gnu-objdump -d $< > dump
|
||||
objcopy -Oihex $< $(TARGET).hex
|
||||
# @echo "Linking complete!"
|
||||
|
||||
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
|
||||
@echo "Compiling "$<" ..."
|
||||
# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(INCDIR) $< -o $@
|
||||
@echo "Done!"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(rm) $(OBJECTS)
|
||||
@echo "Cleanup complete!"
|
||||
|
||||
.PHONY: remove
|
||||
remove: clean
|
||||
@$(rm) $(BINDIR)/$(TARGET)
|
||||
@echo "Executable removed!"
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
#define TRACE (*(unsigned char *)0x40000000)
|
||||
|
||||
void main(void) {
|
||||
int i;
|
||||
for(i=0;i<10;i++) {
|
||||
TRACE = 'a' + i;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
TARGET = trace3
|
||||
|
||||
TARGET_ARCH=riscv32
|
||||
|
||||
CC = riscv32-unknown-linux-gnu-gcc
|
||||
# compiling flags here
|
||||
#CFLAGS = -Wall -I. -O0 -nostartfiles -march=rv32i -mabi=ilp32
|
||||
CFLAGS = -Wall -I. -O0 -nostdlib -march=rv32i -mabi=ilp32 --entry main
|
||||
#CFLAGS = -Wall -I. -O0 -nodefaultlibs -march=rv32i -mabi=ilp32
|
||||
|
||||
|
||||
LINKER = riscv32-unknown-linux-gnu-gcc
|
||||
# linking flags here
|
||||
LFLAGS = -I. --entry main
|
||||
LIBS = $(EXTRA_LIBS)
|
||||
|
||||
|
||||
# change these to proper directories where each file should be
|
||||
SRCDIR = ./
|
||||
OBJDIR = .
|
||||
BINDIR = ./
|
||||
INCDIR = -I.
|
||||
LIBDIR = -L.
|
||||
|
||||
|
||||
SOURCES := $(wildcard $(SRCDIR)/*.c)
|
||||
INCLUDES := $(wildcard $(INCDIR)/*.h)
|
||||
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
|
||||
rm = rm -f
|
||||
|
||||
|
||||
$(BINDIR)/$(TARGET): $(OBJECTS)
|
||||
# $(LINKER) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
|
||||
riscv32-unknown-linux-gnu-objdump -d $< > dump
|
||||
objcopy -Oihex $< $(TARGET).hex
|
||||
# @echo "Linking complete!"
|
||||
|
||||
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
|
||||
@echo "Compiling "$<" ..."
|
||||
# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(INCDIR) $< -o $@
|
||||
@echo "Done!"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(rm) $(OBJECTS)
|
||||
@echo "Cleanup complete!"
|
||||
|
||||
.PHONY: remove
|
||||
remove: clean
|
||||
@$(rm) $(BINDIR)/$(TARGET)
|
||||
@echo "Executable removed!"
|
|
@ -0,0 +1,10 @@
|
|||
#define TRACE (*(unsigned char *)0x40000000)
|
||||
|
||||
void main(void) {
|
||||
char msg[] = "abcdefg\n";
|
||||
int i;
|
||||
|
||||
for (i=0; i<5; i++) {
|
||||
TRACE = msg[i];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
.section .text
|
||||
.globl _start
|
||||
_start:
|
||||
# Basic loop
|
||||
ADDI t1, zero, 10 # t1 to 10
|
||||
ADDI t2, zero, 1 #t2 to 1
|
||||
loop:
|
||||
SUB t1, t1, t2
|
||||
BNE t1, zero, loop
|
||||
# END
|
|
@ -0,0 +1,11 @@
|
|||
.section .text
|
||||
.globl _start
|
||||
_start:
|
||||
|
||||
li t1, 150
|
||||
li t2, 300
|
||||
li t3, -250
|
||||
ADD t4, t1, t2
|
||||
ADD t5, t2, t3
|
||||
SUB t6, t2, t1
|
||||
#SUB t7, t1, t2
|
|
@ -0,0 +1,12 @@
|
|||
.section .text
|
||||
.globl _start
|
||||
_start:
|
||||
|
||||
li t1, 150
|
||||
li t2, 300
|
||||
li t3, -250
|
||||
loop:
|
||||
ADD t4, t1, t2
|
||||
ADD t5, t2, t3
|
||||
SUB t6, t2, t1
|
||||
J loop
|
|
@ -0,0 +1,8 @@
|
|||
li t1, 0xCAFE
|
||||
li t2, 300
|
||||
li t3, 0xBEEF
|
||||
sb t1, -6(t2)
|
||||
sb t3, -13(t2)
|
||||
li t1, 23
|
||||
lbu t1, -6(t2)
|
||||
lbu t3, -13(t2)
|
|
@ -0,0 +1,34 @@
|
|||
.equ TRACE_BASE, 0x40000000
|
||||
|
||||
#msg:
|
||||
# .string "Hello World\n"
|
||||
|
||||
.section .text
|
||||
.globl _start
|
||||
|
||||
_start:
|
||||
li a2, TRACE_BASE
|
||||
li t0, 'H'
|
||||
sb t0, 0(a2)
|
||||
li t0, 'e'
|
||||
sb t0, 0(a2)
|
||||
li t0, 'l'
|
||||
sb t0, 0(a2)
|
||||
li t0, 'l'
|
||||
sb t0, 0(a2)
|
||||
li t0, 'o'
|
||||
sb t0, 0(a2)
|
||||
li t0, ' '
|
||||
sb t0, 0(a2)
|
||||
li t0, 'w'
|
||||
sb t0, 0(a2)
|
||||
li t0, 'o'
|
||||
sb t0, 0(a2)
|
||||
li t0, 'r'
|
||||
sb t0, 0(a2)
|
||||
li t0, 'l'
|
||||
sb t0, 0(a2)
|
||||
li t0, 'd'
|
||||
sb t0, 0(a2)
|
||||
li t0, '\n'
|
||||
sb t0, 0(a2)
|
Loading…
Reference in New Issue