mirror of
https://github.com/plctlab/riscv-operating-system-mooc.git
synced 2025-11-16 12:34:47 +00:00
updated before 3rd class
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
/*
|
||||
* a0 --> a
|
||||
* a1 --> b
|
||||
* c <-- a0
|
||||
*/
|
||||
int foo(int a, int b)
|
||||
{
|
||||
int sum = a + b;
|
||||
return sum;
|
||||
int c = a + b;
|
||||
return c;
|
||||
}
|
||||
@@ -7,13 +7,18 @@
|
||||
_start:
|
||||
la sp, stack_end # prepare stack for calling functions
|
||||
|
||||
# RISC-V uses a0 ~ a7 to transfer parameters
|
||||
li a0, 1
|
||||
li a1, 2
|
||||
call foo
|
||||
# RISC-V uses a0 & a1 to transfer return value
|
||||
# check value of a0
|
||||
|
||||
stop:
|
||||
j stop # Infinite loop to stop execution
|
||||
|
||||
nop # just for demo effect
|
||||
|
||||
stack_start:
|
||||
.rept 10
|
||||
.word 0
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
int foo(int a, int b)
|
||||
{
|
||||
int sum;
|
||||
asm volatile(
|
||||
"nop\n"
|
||||
int c;
|
||||
|
||||
asm volatile (
|
||||
"add %[sum], %[add1], %[add2]"
|
||||
:[sum]"=r"(c)
|
||||
:[add1]"r"(a), [add2]"r"(b)
|
||||
);
|
||||
|
||||
/*
|
||||
asm volatile (
|
||||
"add %0, %1, %2"
|
||||
:"=r"(sum)
|
||||
:"=r"(c)
|
||||
:"r"(a), "r"(b)
|
||||
);
|
||||
return sum;
|
||||
*/
|
||||
return c;
|
||||
}
|
||||
@@ -14,6 +14,8 @@ _start:
|
||||
stop:
|
||||
j stop # Infinite loop to stop execution
|
||||
|
||||
nop # just for demo effect
|
||||
|
||||
stack_start:
|
||||
.rept 10
|
||||
.word 0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
QEMU = qemu-system-riscv32
|
||||
QFLAGS = -nographic -smp 1 -machine virt -bios none
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
SYSCALL = y
|
||||
|
||||
CROSS_COMPILE = riscv64-unknown-elf-
|
||||
CFLAGS = -nostdlib -fno-builtin -mcmodel=medany -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
CFLAGS = -nostdlib -fno-builtin -march=rv32ima -mabi=ilp32 -g -Wall
|
||||
|
||||
ifeq ($(SYSCALL), y)
|
||||
CFLAGS += -D CONFIG_SYSCALL
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Reference in New Issue
Block a user