-// fprintf(stderr, "main function= %p (%s)\thas body= %d\n", mainf, (mainf?mainf->name:NULL), mainf?IFFUNC_HASBODY(mainf->type):-1);
-
- addSetHead(&tmpfileSet,ovrFile);
- pic16_pCodeInitRegisters();
-
- if (mainf && IFFUNC_HASBODY(mainf->type)) {
- pBlock *pb = pic16_newpCodeChain(NULL,'X',pic16_newpCodeCharP("; Starting pCode block"));
-
- pic16_addpBlock(pb);
-
- /* entry point @ start of CSEG */
- pic16_addpCode2pBlock(pb,pic16_newpCodeLabel("__sdcc_program_startup",-1));
-
- if(initsfpnt) {
- pic16_addpCode2pBlock(pb, pic16_newpCode(POC_LFSR,
- pic16_popGetLit2(1, pic16_newpCodeOpRegFromStr("_stack_end"))));
- pic16_addpCode2pBlock(pb, pic16_newpCode(POC_LFSR,
- pic16_popGetLit2(2, pic16_newpCodeOpRegFromStr("_stack_end"))));
- }
-
- /* put in the call to main */
- pic16_addpCode2pBlock(pb,pic16_newpCode(POC_CALL,pic16_newpCodeOp("_main",PO_STR)));
-
- if (options.mainreturn) {
- pic16_addpCode2pBlock(pb,pic16_newpCodeCharP(";\treturn from main will return to caller\n"));
- pic16_addpCode2pBlock(pb,pic16_newpCode(POC_RETURN,NULL));
- } else {
- pic16_addpCode2pBlock(pb,pic16_newpCodeCharP(";\treturn from main will lock up\n"));
- pic16_addpCode2pBlock(pb,pic16_newpCode(POC_GOTO,pic16_newpCodeOp("$",PO_STR)));
- }
- }
-
- /* At this point we've got all the code in the form of pCode structures */
- /* Now it needs to be rearranged into the order it should be placed in the */
- /* code space */
-
- pic16_movepBlock2Head('P'); // Last
- pic16_movepBlock2Head(code->dbName);
- pic16_movepBlock2Head('X');
- pic16_movepBlock2Head(statsg->dbName); // First
-
- /* print the global struct definitions */
-// if (options.debug)
-// cdbStructBlock (0); //,cdbFile);
-
- vFile = tempfile();
- /* PENDING: this isnt the best place but it will do */
- if (port->general.glue_up_main) {
- /* create the interrupt vector table */
- pic16createInterruptVect (vFile);
- }
-
- addSetHead(&tmpfileSet,vFile);
-
- /* emit code for the all the variables declared */
- pic16emitMaps ();
- /* do the overlay segments */
- pic16emitOverlay(ovrFile);
- pic16_AnalyzepCode('*');
+ pic16_pCodeInitRegisters();
+
+ if(pic16_options.no_crt && mainf && IFFUNC_HASBODY(mainf->type)) {
+ pBlock *pb = pic16_newpCodeChain(NULL,'X',pic16_newpCodeCharP("; Starting pCode block"));
+
+ pic16_addpBlock(pb);
+
+ /* entry point @ start of CSEG */
+ pic16_addpCode2pBlock(pb,pic16_newpCodeLabel("__sdcc_program_startup",-1));
+
+ if(initsfpnt) {
+ pic16_addpCode2pBlock(pb, pic16_newpCode(POC_LFSR,
+ pic16_popGetLit2(1, pic16_newpCodeOpRegFromStr("_stack_end"))));
+ pic16_addpCode2pBlock(pb, pic16_newpCode(POC_LFSR,
+ pic16_popGetLit2(2, pic16_newpCodeOpRegFromStr("_stack_end"))));
+ }
+
+ /* put in the call to main */
+ pic16_addpCode2pBlock(pb,pic16_newpCode(POC_CALL,pic16_newpCodeOp("_main",PO_STR)));
+
+ if (options.mainreturn) {
+ pic16_addpCode2pBlock(pb,pic16_newpCodeCharP(";\treturn from main will return to caller\n"));
+ pic16_addpCode2pBlock(pb,pic16_newpCode(POC_RETURN,NULL));
+ } else {
+ pic16_addpCode2pBlock(pb,pic16_newpCodeCharP(";\treturn from main will lock up\n"));
+ pic16_addpCode2pBlock(pb,pic16_newpCode(POC_GOTO,pic16_newpCodeOp("$",PO_STR)));
+ }
+ }
+
+ /* At this point we've got all the code in the form of pCode structures */
+ /* Now it needs to be rearranged into the order it should be placed in the */
+ /* code space */
+
+ pic16_movepBlock2Head('P'); // Last
+ pic16_movepBlock2Head(code->dbName);
+ pic16_movepBlock2Head('X');
+ pic16_movepBlock2Head(statsg->dbName); // First
+
+ /* print the global struct definitions */
+
+ /* PENDING: this isnt the best place but it will do */
+ if (port->general.glue_up_main) {
+ /* create the interrupt vector table */
+ pic16createInterruptVect (&vBuf);
+ }
+
+ /* emit code for the all the variables declared */
+ pic16emitMaps ();
+
+ /* do the overlay segments */
+ pic16emitOverlay(&ovrBuf);
+ pic16_AnalyzepCode('*');