]> git.sur5r.net Git - cc65/blobdiff - src/cc65/codeseg.c
Collect more info on zp registers
[cc65] / src / cc65 / codeseg.c
index 98bc0c27b1b8ecf5ac4ebbcea0a50d8f3a10c8e4..cc4ee7364045097cf91e7b2a67b2d0f49db22fd3 100644 (file)
@@ -323,7 +323,7 @@ static CodeEntry* ParseInsn (CodeSeg* S, LineInfo* LI, const char* L)
                if ((OPC->Info & OF_BRA) != 0) {
                    /* Branch */
                    AM = AM65_BRA;
-               } else if (IsZPName (Arg)) {
+               } else if (IsZPName (Arg, 0)) {
                    AM = AM65_ZP;
                } else {
                    AM = AM65_ABS;
@@ -338,7 +338,7 @@ static CodeEntry* ParseInsn (CodeSeg* S, LineInfo* LI, const char* L)
                    Reg = toupper (*L);
                    L = SkipSpace (L+1);
                    if (Reg == 'X') {
-                       if (IsZPName (Arg)) {
+                       if (IsZPName (Arg, 0)) {
                            AM = AM65_ZPX;
                        } else {
                            AM = AM65_ABSX;
@@ -397,6 +397,7 @@ CodeSeg* NewCodeSeg (const char* SegName, SymEntry* Func)
 /* Create a new code segment, initialize and return it */
 {
     unsigned I;
+    const type* RetType;
 
     /* Allocate memory */
     CodeSeg* S = xmalloc (sizeof (CodeSeg));
@@ -413,8 +414,13 @@ CodeSeg* NewCodeSeg (const char* SegName, SymEntry* Func)
     /* If we have a function given, get the return type of the function.
      * Assume ANY return type besides void will use the A and X registers.
      */
-    if (S->Func && !IsTypeVoid (GetFuncReturn (Func->Type))) {
-       S->ExitRegs = REG_AX;
+    RetType = GetFuncReturn (Func->Type);
+    if (S->Func && !IsTypeVoid (RetType)) {
+       if (SizeOf (RetType) == SizeOf (type_long)) {
+           S->ExitRegs = REG_EAX;
+       } else {
+           S->ExitRegs = REG_AX;
+       }
     } else {
        S->ExitRegs = REG_NONE;
     }
@@ -484,7 +490,7 @@ void CS_AddVLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap)
 
 void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, ...)
 /* Add a line to the given code segment */
-{    
+{
     va_list ap;
     va_start (ap, Format);
     CS_AddVLine (S, LI, Format, ap);