added initial linker script and tartup asm code
[my-code/arm.git] / betty / startup.s
diff --git a/betty/startup.s b/betty/startup.s
new file mode 100644 (file)
index 0000000..bc4ff41
--- /dev/null
@@ -0,0 +1,47 @@
+#
+# startup.s - starup code for the lpc2220
+#
+# author: hackbard@hackdaworld.org
+#
+
+#
+# some definitions
+#
+
+# sram
+
+.equ   sram_size,      (64*1024)
+.equ   sram_addr,      0x40000000
+.equ   sram_top,       (sram_addr+sram_size-4)
+
+# stack
+
+.equ   stack_size,     (2*1024)
+.equ   stack_top,      sram_top
+.equ   stack_limit,    (sram_top-stack_size)
+
+#
+# the startup code
+#
+
+.text
+.arm
+
+       # init stack pointer
+
+       ldr r0, =sram_top
+       mov sp, r0
+       ldr r0, =stack_limit
+       mov sl, r0
+
+       # jump to c code
+
+       adr lr, loop_forever
+       mov r0, #0
+       mov r1, #0
+       ldr r2, =main
+       bx r2
+
+loop_forever:
+       b loop_forever
+