]> oss.titaniummirror.com Git - msp430-libc.git/blobdiff - src/stdlib/__do_copy_data.S
Imported msp430-libc-20100207
[msp430-libc.git] / src / stdlib / __do_copy_data.S
diff --git a/src/stdlib/__do_copy_data.S b/src/stdlib/__do_copy_data.S
new file mode 100644 (file)
index 0000000..dcab439
--- /dev/null
@@ -0,0 +1,27 @@
+/*****************************************************************
+ * Initialize data: copy data 
+ * from __data_load_start ( = _etext) to __data_start
+ * can be overwriten by user function with the same name
+ *****************************************************************/
+        .section .init4, "ax", @progbits
+
+        .weak   __do_copy_data
+        .func   __do_copy_data
+
+__do_copy_data:
+        mov     #__data_size, r15
+        tst     r15
+        jz      .L__copy_data_end
+.L__copy_data_loop:
+        decd    r15
+#if defined(__MSP430X__) && !defined(__MSP430X_ADDR_16BIT__)
+        ; __data_load_start can be anywhere, use 430X instruction
+        movx.w  __data_load_start(r15), __data_start(r15)    ; data section is word-aligned, so word transfer is acceptable
+#else
+        ; __data_load_start is in lower 64K, RAM is in lower 64K, use 430 instruction
+        mov.w   __data_load_start(r15), __data_start(r15)    ; data section is word-aligned, so word transfer is acceptable
+#endif
+        jne     .L__copy_data_loop
+.L__copy_data_end:
+
+        .endfunc