EXEEXT introduces to solve Cygwin problems
[fw/sdcc] / as / mcs51 / lkmem.c
index c5b3d94342ca4609863881524e0fe9d1f25f9400..6a2d8770c5563cea8cd604be87a9583eb3329ed4 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include "aslink.h"
+#include "strcmpi.h"
 
 int summary(struct area * areap) 
 {
-       #define EQ(A,B) !strcmpi((A),(B))
+       #define EQ(A,B) !as_strcmpi((A),(B))
        #define MIN_STACK 16
        #define REPORT_ERROR(A, H) \
        {\
@@ -251,7 +252,8 @@ int summary(struct area * areap)
        }
 
        /*Report the position of the begining of the stack*/
-       fprintf(of, "\nStack starts at: 0x%02lx", Stack.Start);
+       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 )
@@ -267,7 +269,7 @@ int summary(struct area * areap)
                REPORT_ERROR(buff, 1);
                for(j=0; j<7; j++)
                {
-                       if(dram[Stack.Start]&Ram[j].flag)
+                               if(dram[Stack.Start]&Ram[j].flag)
                        {
                                sprintf(buff, "'%s'\n", Ram[j].Name);
                                break;
@@ -279,14 +281,14 @@ int summary(struct area * areap)
                }
                REPORT_ERROR(buff, 0);
        }
-       else    
+       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 (k<MIN_STACK)
                {
                        sprintf(buff, "Only %d byte%s available for stack.\n",
-                                       k, (k==1)?"":"s");
+                               k, (k==1)?"":"s");
                        REPORT_WARNING(buff, 1);
                }
        }
@@ -312,7 +314,7 @@ int summary(struct area * areap)
        else
                sprintf(end,  "0x%04lx", XRam.Size+XRam.Start-1);
        sprintf(size, "%5lu", XRam.Size);
-       sprintf(max, "%5lu", XRam.Max);
+       sprintf(max, "%5lu", xram_size<0?XRam.Max:xram_size);
        fprintf(of, format, XRam.Name, start, end, size, max);
 
        /*Report Rom/Flash totals:*/
@@ -322,7 +324,7 @@ int summary(struct area * areap)
        else
                sprintf(end,  "0x%04lx", Rom.Size+Rom.Start-1);
        sprintf(size, "%5lu", Rom.Size);
-       sprintf(max, "%5lu", Rom.Max);
+       sprintf(max, "%5lu", code_size<0?Rom.Max:code_size);
        fprintf(of, format, Rom.Name, start, end, size, max);
 
        /*Report any excess:*/
@@ -331,12 +333,14 @@ int summary(struct area * areap)
                sprintf(buff, "Insufficient INDIRECT RAM memory.\n");
                REPORT_ERROR(buff, 1);
        }
-       if((XRam.Start+XRam.Size)>XRam.Max)
+       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)
+       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);