* device/include/asm/pic16/features.h,
[fw/sdcc] / device / lib / pic16 / startup / crt0iz.c
index 8e62153671864059aa1181186216525beab990d5..a3ae4722d9362f1a51a411c150298faaab9179fc 100644 (file)
@@ -49,26 +49,26 @@ char __uflags = 0;
 extern void main (void);
 
 /* prototype for the startup function */
-void _entry (void) _naked interrupt 0;
-void _startup (void) _naked;
+void _entry (void) __naked __interrupt 0;
+void _startup (void) __naked;
 
 /* prototype for the initialized data setup */
-void _do_cinit (void) _naked;
+void _do_cinit (void) __naked;
 
 
 /*
  * entry function, placed at interrupt vector 0 (RESET)
  */
 
-void _entry (void) _naked interrupt 0
+void _entry (void) __naked __interrupt 0
 {
-  _asm goto __startup _endasm;
+  __asm goto __startup __endasm;
 }
 
 
-void _startup (void) _naked
+void _startup (void) __naked
 {
-  _asm
+  __asm
     // Initialize the stack pointer
     lfsr 1, _stack_end
     lfsr 2, _stack_end
@@ -78,10 +78,10 @@ void _startup (void) _naked
     // for non-flash devices, so we do it on all parts.
     bsf 0xa6, 7, 0
     bcf 0xa6, 6, 0
-  _endasm ;
+  __endasm ;
     
   /* cleanup the RAM */
-  _asm
+  __asm
     /* load FSR0 with top of RAM memory */
         ; movlw 0xff
         ; movwf _FSR0L, 0
@@ -99,10 +99,10 @@ void _startup (void) _naked
     movlw 0x00
                
 clear_loop:
-    movwf _POSTDEC0
+    clrf _POSTDEC0
     movf 0x00, w
     bnz clear_loop
-  _endasm ;
+  __endasm ;
 
   _do_cinit();
 
@@ -116,7 +116,7 @@ loop:
 
 
 /* the cinit table will be filled by the linker */
-extern code struct
+extern __code struct
 {
   unsigned short num_init;
   struct _init_entry {
@@ -142,13 +142,13 @@ extern code struct
  */
 
 /* the variable initialisation routine */
-void _do_cinit (void) _naked
+void _do_cinit (void) __naked
 {
   /*
    * access registers 0x00 - 0x09 are not saved in this function
    */
 
-  _asm
+  __asm
       ; TBLPTR = &cinit
     movlw low(_cinit)
     movwf _TBLPTRL
@@ -169,7 +169,7 @@ void _do_cinit (void) _naked
 
                   ; while (curr_entry) {
 test:
-    bnz done1
+    bnz cont1           ;;done1
     tstfsz curr_entry, 1
     bra cont1
 
@@ -217,7 +217,7 @@ cont1:
     TBLRDPOSTINC
     TBLRDPOSTINC
 
-    ; read the destination address directly into FSR0 
+    ; read the size of data to transfer to destination address 
     TBLRDPOSTINC
     movf _TABLAT, w
     movwf curr_byte
@@ -270,10 +270,10 @@ copy_one_byte:
 
     ; decrement byte counter 
     decf curr_byte, f
-    bnc copy_loop              ; copy_loop 
+    bc copy_loop               ; copy_loop 
     decf curr_byte + 1, f
 
-    bra copy_loop
+    bra copy_one_byte
 done_copying:
 
   
@@ -284,9 +284,11 @@ done_copying:
     movff data_ptr + 2, _TBLPTRU
 
 
-    dcfsnz curr_entry, f
+    decf curr_entry, f
+    bc do_next
     decf curr_entry + 1, f
 
+do_next:
     ; next entry...
     ; _do_cinit_curr_entry--; 
 
@@ -295,6 +297,6 @@ done_copying:
     ; emit done label 
 done:
     return
-  _endasm;
+  __endasm;
 }