aboutsummaryrefslogtreecommitdiff
path: root/prog
diff options
context:
space:
mode:
Diffstat (limited to 'prog')
-rw-r--r--prog/link.ld4
-rw-r--r--prog/src/main.c2
-rw-r--r--prog/src/prog.s (renamed from prog/src/prog.s.bak)37
3 files changed, 12 insertions, 31 deletions
diff --git a/prog/link.ld b/prog/link.ld
index 4cc02ec..7bd11eb 100644
--- a/prog/link.ld
+++ b/prog/link.ld
@@ -43,7 +43,7 @@ SECTIONS
.stack (NOLOAD) :
{
_stack_start = .;
- . += 0x10; /* Adjust the size as needed */
+ . += 0x80; /* Adjust the size as needed */
_stack_end = .;
} > RAM
@@ -51,7 +51,7 @@ SECTIONS
.heap (NOLOAD) :
{
_heap_start = .;
- . += 0x10; /* Adjust the size as needed */
+ . += 0x80; /* Adjust the size as needed */
_heap_end = .;
} > RAM
}
diff --git a/prog/src/main.c b/prog/src/main.c
index 1ce067c..8bcdfe2 100644
--- a/prog/src/main.c
+++ b/prog/src/main.c
@@ -1,6 +1,8 @@
+extern void test_prog(void);
int main(void) {
+ test_prog();
while (1) {
}
}
diff --git a/prog/src/prog.s.bak b/prog/src/prog.s
index 63026c9..ec227a9 100644
--- a/prog/src/prog.s.bak
+++ b/prog/src/prog.s
@@ -1,11 +1,5 @@
.section .text
-.globl _start
-
-_start:
-
-
- j test_prog
-
+.globl test_prog
/*
@@ -18,9 +12,6 @@ loop:
j loop
*/
-halt_loop:
- j halt_loop
-
test_prog:
li t0, 0xFFFFFFFF
li t1, 0x33333333
@@ -45,19 +36,25 @@ test_prog:
beq t0, t0, branch_eq
j branch_eq_nt
+end:
+ ret
branch_eq_ret:
beq t0, t3, branch_ne
j branch_ne_nt
branch_ne_ret:
+ addi sp, sp, -16 # Adjust stack pointer to make space for ra and s0
+ sw ra, 0(sp) # Save ra to the stack
call func
+ lw ra, 0(sp) # Load ra from the stack
+ addi sp, sp, 16 # Restore stack pointer
li t0, 0x00100000
sw t1, 0(t0)
lw t2, 0(t0)
- j halt_loop
+ j end
branch_eq:
@@ -79,21 +76,3 @@ branch_ne_nt:
func:
addi t5, zero, 5
ret
-
-
-
-
-
-
-
-
-
-
-.section .data
-
-
-.section .bss
-
-.section .stack
- .space 0x1000 # Allocate stack space
-stack_top: