mirror of
https://github.com/plctlab/riscv-operating-system-mooc.git
synced 2025-12-26 01:08:04 +00:00
initial versioin
This commit is contained in:
7
code/asm/asm2c/Makefile
Normal file
7
code/asm/asm2c/Makefile
Normal file
@@ -0,0 +1,7 @@
|
||||
EXEC = test
|
||||
|
||||
SRC = $(EXEC).s $(EXEC).c
|
||||
|
||||
GDBINIT = ./gdbinit
|
||||
|
||||
include ../rule.mk
|
||||
9
code/asm/asm2c/gdbinit
Normal file
9
code/asm/asm2c/gdbinit
Normal file
@@ -0,0 +1,9 @@
|
||||
display/z $sp
|
||||
display/z $ra
|
||||
display/z $a0
|
||||
display/z $a1
|
||||
|
||||
set disassemble-next-line on
|
||||
b _start
|
||||
target remote : 1234
|
||||
c
|
||||
5
code/asm/asm2c/test.c
Normal file
5
code/asm/asm2c/test.c
Normal file
@@ -0,0 +1,5 @@
|
||||
int foo(int a, int b)
|
||||
{
|
||||
int sum = a + b;
|
||||
return sum;
|
||||
}
|
||||
23
code/asm/asm2c/test.s
Normal file
23
code/asm/asm2c/test.s
Normal file
@@ -0,0 +1,23 @@
|
||||
# ASM call C
|
||||
|
||||
.text # Define beginning of text section
|
||||
.global _start # Define entry _start
|
||||
.global foo #
|
||||
|
||||
_start: # Label, not really required
|
||||
la sp, stack_end # prepare stack for calling functions
|
||||
|
||||
li a0, 1
|
||||
li a1, 2
|
||||
call foo
|
||||
|
||||
stop:
|
||||
j stop # Infinite loop to stop execution
|
||||
|
||||
stack_start:
|
||||
.rept 10
|
||||
.word 0
|
||||
.endr
|
||||
stack_end:
|
||||
|
||||
.end # End of file
|
||||
Reference in New Issue
Block a user