aboutsummaryrefslogtreecommitdiff
path: root/prog/src
diff options
context:
space:
mode:
Diffstat (limited to 'prog/src')
-rw-r--r--prog/src/main.c6
-rw-r--r--prog/src/prog.s.bak (renamed from prog/src/prog.s)0
-rw-r--r--prog/src/startup.s42
3 files changed, 48 insertions, 0 deletions
diff --git a/prog/src/main.c b/prog/src/main.c
new file mode 100644
index 0000000..1ce067c
--- /dev/null
+++ b/prog/src/main.c
@@ -0,0 +1,6 @@
+
+
+int main(void) {
+ while (1) {
+ }
+}
diff --git a/prog/src/prog.s b/prog/src/prog.s.bak
index 63026c9..63026c9 100644
--- a/prog/src/prog.s
+++ b/prog/src/prog.s.bak
diff --git a/prog/src/startup.s b/prog/src/startup.s
new file mode 100644
index 0000000..7adfb5e
--- /dev/null
+++ b/prog/src/startup.s
@@ -0,0 +1,42 @@
+.section .init
+.globl _start
+_start:
+ /* Set up stack pointer */
+ la sp, _stack_end
+
+ /* Initialize .data section (copy from LMA to VMA) */
+ la t0, _sdata /* VMA start of .data */
+ la t1, _edata /* VMA end of .data */
+ la t2, _etext /* LMA start of .data in flash */
+copy_data:
+ beq t0, t1, clear_bss
+ lw t3, 0(t2)
+ sw t3, 0(t0)
+ addi t0, t0, 4
+ addi t2, t2, 4
+ j copy_data
+
+clear_bss:
+ /* Clear .bss section */
+ la t0, _sbss /* VMA start of .bss */
+ la t1, _ebss /* VMA end of .bss */
+clear_loop:
+ beq t0, t1, init_libc
+ sw x0, 0(t0)
+ addi t0, t0, 4
+ j clear_loop
+
+init_libc:
+ /* Call libc initialization functions */
+ /* call _init */
+
+ /* Call main function */
+ call main
+
+finalize_libc:
+ /* Call libc finalization functions */
+ /* call _fini */
+
+halt:
+ /* Infinite loop after main returns */
+ j halt