View Single Post
  #1   Spotlight this post!  
Unread 26-10-2003, 16:21
ScottWolchok ScottWolchok is offline
Pwnt.
#0217 (ThunderChickens)
Team Role: Programmer
 
Join Date: Oct 2003
Rookie Year: 2004
Location: Utica, MI
Posts: 23
ScottWolchok will become famous soon enoughScottWolchok will become famous soon enough
Send a message via AIM to ScottWolchok
Weird Stuff in ifi_startup.c

I was poking through the default code in an effort to determine if we could program the Master PIC as well as the User PIC, and I found this odd stuff thither.
Code:
void
_entry (void)
{
_asm goto _startup _endasm

}
#pragma code _startup_scn
void
_startup (void)
{
  _asm
    // Initialize the stack pointer
    lfsr 1, _stack lfsr 2, _stack clrf TBLPTRU, 0 // 1st silicon doesn't do this o
n POR
    bcf  FPFLAGS,RND,0 // Initialize rounding flag for floating point libs
    
    // initialize the flash memory access configuration. this is harmless
    // for non-flash devices, so we do it on all parts.
    bsf 0xa6, 7, 0
    bcf 0xa6, 6, 0
  _endasm 

loop:

        Clear_Memory();              
  _do_cinit ();
  // Call the user's main routine
  main ();

  goto loop;
}                               /* end _startup() */
Mmkay, so I look at this and I'm really lost. First of all, what does the underscore at the start of all these functions signify? Second, isn't assembler in C done like a function call? Thirdly, is that entry function even necessary? And last, I thought C programs started with the main function, but this code calls it instead... @_@