- }
-
- for(j=0; j<7; j++)
- for(k=Ram[j].Start; (k<(Ram[j].Start+Ram[j].Size))&&(k<0x100); k++)
- dram[k]|=Ram[j].flag; /*Mark as used*/
-
- for(k=IRam.Start; (k<(IRam.Start+IRam.Size))&&(k<0x100); k++)
- dram[k]|=IRam.flag; /*Mark as used*/
-
- /*Compute the amount of unused memory in direct data Ram. This is the
- gap between the last register bank or bit segment and the data segment.*/
- for(k=Ram[6].Start-1; (dram[k]==0) && (k>0); k--);
- Ram[5].Start=k+1;
- Ram[5].Size=Ram[6].Start-Ram[5].Start; /*It may be zero (which is good!)*/
-
- /*Compute the data Ram totals*/
- for(j=0; j<7; j++)
- {
- if(Ram[7].Start>Ram[j].Start) Ram[7].Start=Ram[j].Start;
- Ram[7].Size+=Ram[j].Size;
- }
- Total_Last=Ram[6].Size+Ram[6].Start-1;
-
- /*Report the Ram totals*/
- fprintf(of, "Direct Internal RAM:\n");
- fprintf(of, format, "Name", "Start", "End", "Size", "Max");
-
- for(j=0; j<8; j++)
- {
- if((j==0) || (j==7)) fprintf(of, format, line, line, line, line, line);
- if((j!=5) || (Ram[j].Size>0))
- {
- sprintf(start, "0x%02lx", Ram[j].Start);
- if(Ram[j].Size==0)
- end[0]=0;/*Empty string*/
- else
- sprintf(end, "0x%02lx", j==7?Total_Last:Ram[j].Size+Ram[j].Start-1);
- sprintf(size, "%5lu", Ram[j].Size);
- sprintf(max, "%5lu", Ram[j].Max);
- fprintf(of, format, Ram[j].Name, start, end, size, max);
- }
- }
-
- for(k=Ram[6].Start; (k<(Ram[6].Start+Ram[6].Size))&&(k<0x100); k++)
- {
- if(dram[k]!=Ram[6].flag)
- {
- sprintf(buff, "Internal memory overlap starting at 0x%02x.\n", k);
- REPORT_ERROR(buff, 1);
- break;
- }
- }
-
- if(Ram[4].Size>Ram[4].Max)
- {
- k=Ram[4].Size-Ram[4].Max;
- sprintf(buff, "Insufficient bit addressable memory. "
- "%d byte%s short.\n", k, (k==1)?"":"s");
- REPORT_ERROR(buff, 1);
- }
-
- if(Ram[5].Size!=0)
- {
- sprintf(buff, "%ld bytes in data memory wasted. "
- "SDCC link could use: --data-loc 0x%02lx\n",
- Ram[5].Size, Ram[6].Start-Ram[5].Size);
- REPORT_WARNING(buff, 1);
- }
-
- if((Ram[6].Start+Ram[6].Size)>Ram[6].Max)
- {
- k=(Ram[6].Start+Ram[6].Size)-Ram[6].Max;
- sprintf(buff, "Insufficient space in data memory. "
- "%d byte%s short.\n", k, (k==1)?"":"s");
- REPORT_ERROR(buff, 1);
- }
-
- /*Report the position of the begining of the stack*/
- fprintf(of, "\n%stack starts at: 0x%02lx (sp set to 0x%02lx)",
- rflag ? "16 bit mode initial s" : "S", Stack.Start, Stack.Start-1);
-
- /*Check that the stack pointer is landing in a safe place:*/
- if( (dram[Stack.Start] & 0x8000) == 0x8000 )
- {
- fprintf(of, ".\n");
- sprintf(buff, "Stack set to unavailable memory.\n");
- REPORT_ERROR(buff, 1);
- }
- else if(dram[Stack.Start])
- {
- fprintf(of, ".\n");
- sprintf(buff, "Stack overlaps area ");
- REPORT_ERROR(buff, 1);
- for(j=0; j<7; j++)
- {
- if(dram[Stack.Start]&Ram[j].flag)
- {
- sprintf(buff, "'%s'\n", Ram[j].Name);
- break;
- }
- }
- if(dram[Stack.Start]&IRam.flag)
- {
- sprintf(buff, "'%s'\n", IRam.Name);
- }
- REPORT_ERROR(buff, 0);
- }
- else
- {
- for(j=Stack.Start, k=0; (j<(int)iram_size)&&(dram[j]==0); j++, k++);
- fprintf(of, " with %d bytes available\n", k);
- if ((int)k<stacksize)
- {
- sprintf(buff, "Only %d byte%s available for stack.\n",
- k, (k==1)?"":"s");
- REPORT_WARNING(buff, 1);
- }
- }
-
- fprintf(of, "\nOther memory:\n");
- fprintf(of, format, "Name", "Start", "End", "Size", "Max");
- fprintf(of, format, line, line, line, line, line);
-
- /*Report IRam totals:*/
- if(IRam.Size==0)
- {
- start[0]=0;/*Empty string*/
- end[0]=0;/*Empty string*/
- }
- else
- {
- sprintf(start, "0x%02lx", IRam.Start);
- sprintf(end, "0x%02lx", IRam.Size+IRam.Start-1);
- }
- sprintf(size, "%5lu", IRam.Size);
- sprintf(max, "%5lu", IRam.Max);
- fprintf(of, format, IRam.Name, start, end, size, max);
-
- /*Report XRam totals:*/
- if(XRam.Size==0)
- {
- start[0]=0;/*Empty string*/
- end[0]=0;/*Empty string*/
- }
- else
- {
- sprintf(start, "0x%04lx", XRam.Start);
- sprintf(end, "0x%04lx", XRam.Size+XRam.Start-1);
- }
- sprintf(size, "%5lu", XRam.Size);
- sprintf(max, "%5lu", xram_size<0?XRam.Max:xram_size);
- fprintf(of, format, XRam.Name, start, end, size, max);
-
- /*Report Rom/Flash totals:*/
- if(Rom.Size==0)
- {
- start[0]=0;/*Empty string*/
- end[0]=0;/*Empty string*/
- }
- else
- {
- sprintf(start, "0x%04lx", Rom.Start);
- sprintf(end, "0x%04lx", Rom.Size+Rom.Start-1);
- }
- sprintf(size, "%5lu", Rom.Size);
- sprintf(max, "%5lu", code_size<0?Rom.Max:code_size);
- fprintf(of, format, Rom.Name, start, end, size, max);
-
- /*Report any excess:*/
- if((IRam.Start+IRam.Size)>(IRam.Max+0x80))
- {
- sprintf(buff, "Insufficient INDIRECT RAM memory.\n");
- REPORT_ERROR(buff, 1);
- }
- if( ((XRam.Start+XRam.Size)>XRam.Max) ||
- (((int)XRam.Size>xram_size)&&(xram_size>=0)) )
- {
- sprintf(buff, "Insufficient EXTERNAL RAM memory.\n");
- REPORT_ERROR(buff, 1);
- }
- if( ((Rom.Start+Rom.Size)>Rom.Max) ||
- (((int)Rom.Size>code_size)&&(code_size>=0)) )
- {
- sprintf(buff, "Insufficient ROM/EPROM/FLASH memory.\n");
- REPORT_ERROR(buff, 1);
- }
-
- fclose(of);
- return toreturn;
+ }
+
+ for(j=0; j<7; j++)
+ for(k=Ram[j].Start; (k<(Ram[j].Start+Ram[j].Size))&&(k<0x100); k++)
+ dram[k]|=Ram[j].flag; /*Mark as used*/
+
+ for(k=IRam.Start; (k<(IRam.Start+IRam.Size))&&(k<0x100); k++)
+ dram[k]|=IRam.flag; /*Mark as used*/
+
+ /*Compute the amount of unused memory in direct data Ram. This is the
+ gap between the last register bank or bit segment and the data segment.*/
+ for(k=Ram[6].Start-1; (dram[k]==0) && (k>0); k--);
+ Ram[5].Start=k+1;
+ Ram[5].Size=Ram[6].Start-Ram[5].Start; /*It may be zero (which is good!)*/
+
+ /*Compute the data Ram totals*/
+ for(j=0; j<7; j++)
+ {
+ if(Ram[7].Start>Ram[j].Start) Ram[7].Start=Ram[j].Start;
+ Ram[7].Size+=Ram[j].Size;
+ }
+ Total_Last=Ram[6].Size+Ram[6].Start-1;
+
+ /*Report the Ram totals*/
+ fprintf(of, "Direct Internal RAM:\n");
+ fprintf(of, format, "Name", "Start", "End", "Size", "Max");
+
+ for(j=0; j<8; j++)
+ {
+ if((j==0) || (j==7)) fprintf(of, format, line, line, line, line, line);
+ if((j!=5) || (Ram[j].Size>0))
+ {
+ sprintf(start, "0x%02lx", Ram[j].Start);
+ if(Ram[j].Size==0)
+ end[0]=0;/*Empty string*/
+ else
+ sprintf(end, "0x%02lx", j==7?Total_Last:Ram[j].Size+Ram[j].Start-1);
+ sprintf(size, "%5lu", Ram[j].Size);
+ sprintf(max, "%5lu", Ram[j].Max);
+ fprintf(of, format, Ram[j].Name, start, end, size, max);
+ }
+ }
+
+ for(k=Ram[6].Start; (k<(Ram[6].Start+Ram[6].Size))&&(k<0x100); k++)
+ {
+ if(dram[k]!=Ram[6].flag)
+ {
+ sprintf(buff, "Internal memory overlap starting at 0x%02x.\n", k);
+ REPORT_ERROR(buff, 1);
+ break;
+ }
+ }
+
+ if(Ram[4].Size>Ram[4].Max)
+ {
+ k=Ram[4].Size-Ram[4].Max;
+ sprintf(buff, "Insufficient bit addressable memory. "
+ "%d byte%s short.\n", k, (k==1)?"":"s");
+ REPORT_ERROR(buff, 1);
+ }
+
+ if(Ram[5].Size!=0)
+ {
+ sprintf(buff, "%ld bytes in data memory wasted. "
+ "SDCC link could use: --data-loc 0x%02lx\n",
+ Ram[5].Size, Ram[6].Start-Ram[5].Size);
+ REPORT_WARNING(buff, 1);
+ }
+
+ if((Ram[6].Start+Ram[6].Size)>Ram[6].Max)
+ {
+ k=(Ram[6].Start+Ram[6].Size)-Ram[6].Max;
+ sprintf(buff, "Insufficient space in data memory. "
+ "%d byte%s short.\n", k, (k==1)?"":"s");
+ REPORT_ERROR(buff, 1);
+ }
+
+ /*Report the position of the beginning of the stack*/
+ fprintf(of, "\n%stack starts at: 0x%02lx (sp set to 0x%02lx)",
+ rflag ? "16 bit mode initial s" : "S", Stack.Start, Stack.Start-1);
+
+ /*Check that the stack pointer is landing in a safe place:*/
+ if( (dram[Stack.Start] & 0x8000) == 0x8000 )
+ {
+ fprintf(of, ".\n");
+ sprintf(buff, "Stack set to unavailable memory.\n");
+ REPORT_ERROR(buff, 1);
+ }
+ else if(dram[Stack.Start])
+ {
+ fprintf(of, ".\n");
+ sprintf(buff, "Stack overlaps area ");
+ REPORT_ERROR(buff, 1);
+ for(j=0; j<7; j++)
+ {
+ if(dram[Stack.Start]&Ram[j].flag)
+ {
+ sprintf(buff, "'%s'\n", Ram[j].Name);
+ break;
+ }
+ }
+ if(dram[Stack.Start]&IRam.flag)
+ {
+ sprintf(buff, "'%s'\n", IRam.Name);
+ }
+ REPORT_ERROR(buff, 0);
+ }
+ else
+ {
+ for(j=Stack.Start, k=0; (j<(int)iram_size)&&(dram[j]==0); j++, k++);
+ fprintf(of, " with %d bytes available\n", k);
+ if ((int)k<stacksize)
+ {
+ sprintf(buff, "Only %d byte%s available for stack.\n",
+ k, (k==1)?"":"s");
+ REPORT_WARNING(buff, 1);
+ }
+ }
+
+ fprintf(of, "\nOther memory:\n");
+ fprintf(of, format, "Name", "Start", "End", "Size", "Max");
+ fprintf(of, format, line, line, line, line, line);
+
+ /*Report IRam totals:*/
+ if(IRam.Size==0)
+ {
+ start[0]=0;/*Empty string*/
+ end[0]=0;/*Empty string*/
+ }
+ else
+ {
+ sprintf(start, "0x%02lx", IRam.Start);
+ sprintf(end, "0x%02lx", IRam.Size+IRam.Start-1);
+ }
+ sprintf(size, "%5lu", IRam.Size);
+ sprintf(max, "%5lu", IRam.Max);
+ fprintf(of, format, IRam.Name, start, end, size, max);
+
+ /*Report XRam totals:*/
+ if(XRam.Size==0)
+ {
+ start[0]=0;/*Empty string*/
+ end[0]=0;/*Empty string*/
+ }
+ else
+ {
+ sprintf(start, "0x%04lx", XRam.Start);
+ sprintf(end, "0x%04lx", XRam.Size+XRam.Start-1);
+ }
+ sprintf(size, "%5lu", XRam.Size);
+ sprintf(max, "%5lu", xram_size<0?XRam.Max:xram_size);
+ fprintf(of, format, XRam.Name, start, end, size, max);
+
+ /*Report Rom/Flash totals:*/
+ if(Rom.Size==0)
+ {
+ start[0]=0;/*Empty string*/
+ end[0]=0;/*Empty string*/
+ }
+ else
+ {
+ sprintf(start, "0x%04lx", Rom.Start);
+ sprintf(end, "0x%04lx", Rom.Size+Rom.Start-1);
+ }
+ sprintf(size, "%5lu", Rom.Size);
+ sprintf(max, "%5lu", code_size<0?Rom.Max:code_size);
+ fprintf(of, format, Rom.Name, start, end, size, max);
+
+ /*Report any excess:*/
+ if((IRam.Start+IRam.Size)>(IRam.Max+0x80))
+ {
+ sprintf(buff, "Insufficient INDIRECT RAM memory.\n");
+ REPORT_ERROR(buff, 1);
+ }
+ if( ((XRam.Start+XRam.Size)>XRam.Max) ||
+ (((int)XRam.Size>xram_size)&&(xram_size>=0)) )
+ {
+ sprintf(buff, "Insufficient EXTERNAL RAM memory.\n");
+ REPORT_ERROR(buff, 1);
+ }
+ if( ((Rom.Start+Rom.Size)>Rom.Max) ||
+ (((int)Rom.Size>code_size)&&(code_size>=0)) )
+ {
+ sprintf(buff, "Insufficient ROM/EPROM/FLASH memory.\n");
+ REPORT_ERROR(buff, 1);
+ }
+
+ fclose(of);
+ return toreturn;