]> git.sur5r.net Git - cc65/blobdiff - src/da65/attrtab.c
Fix comment typos.
[cc65] / src / da65 / attrtab.c
index 277ee8b0e9ec083e0c94280e4030dc84518dd9ca..a9143584ab81a3a010db6af72d5732ed3c9d8c3b 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                attrtab.c                                 */
+/*                                 attrtab.c                                 */
 /*                                                                           */
-/*                      Disassembler attribute table                        */
+/*                       Disassembler attribute table                        */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2006 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2000-2014, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -40,7 +40,7 @@
 
 
 /*****************************************************************************/
-/*                                  Data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
@@ -51,7 +51,7 @@ static unsigned short AttrTab[0x10000];
 
 
 /*****************************************************************************/
-/*                                  Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -60,12 +60,24 @@ void AddrCheck (unsigned Addr)
 /* Check if the given address has a valid range */
 {
     if (Addr >= 0x10000) {
-       Error ("Address out of range: %08X", Addr);
+        Error ("Address out of range: %08X", Addr);
     }
 }
 
 
 
+attr_t GetAttr (unsigned Addr)
+/* Return the attribute for the given address */
+{
+    /* Check the given address */
+    AddrCheck (Addr);
+
+    /* Return the attribute */
+    return AttrTab[Addr];
+}
+
+
+
 int SegmentDefined (unsigned Start, unsigned End)
 /* Return true if the atSegment bit is set somewhere in the given range */
 {
@@ -75,7 +87,23 @@ int SegmentDefined (unsigned Start, unsigned End)
         }
     }
     return 0;
-}            
+}
+
+
+
+int IsSegmentEnd (unsigned Addr)
+/* Return true if a segment ends at the given address */
+{
+    return (GetAttr (Addr) & atSegmentEnd) != 0x0000;
+}
+
+
+
+int IsSegmentStart (unsigned Addr)
+/* Return true if a segment starts at the given address */
+{
+    return (GetAttr (Addr) & atSegmentStart) != 0x0000;
+}
 
 
 
@@ -83,21 +111,21 @@ unsigned GetGranularity (attr_t Style)
 /* Get the granularity for the given style */
 {
     switch (Style) {
-       case atDefault:  return 1;
-       case atCode:     return 1;
-       case atIllegal:  return 1;
-       case atByteTab:  return 1;
-       case atDByteTab: return 2;
-       case atWordTab:  return 2;
-       case atDWordTab: return 4;
-       case atAddrTab:  return 2;
-       case atRtsTab:   return 2;
-       case atTextTab:  return 1;
-
-       case atSkip:
-       default:
-           Internal ("GetGraularity called for style = %d", Style);
-           return 0;
+        case atDefault:  return 1;
+        case atCode:     return 1;
+        case atIllegal:  return 1;
+        case atByteTab:  return 1;
+        case atDByteTab: return 2;
+        case atWordTab:  return 2;
+        case atDWordTab: return 4;
+        case atAddrTab:  return 2;
+        case atRtsTab:   return 2;
+        case atTextTab:  return 1;
+
+        case atSkip:
+        default:
+            Internal ("GetGraularity called for style = %d", Style);
+            return 0;
     }
 }
 
@@ -108,7 +136,7 @@ void MarkRange (unsigned Start, unsigned End, attr_t Attr)
 {
     /* Do it easy here... */
     while (Start <= End) {
-       MarkAddr (Start++, Attr);
+        MarkAddr (Start++, Attr);
     }
 }
 
@@ -122,9 +150,9 @@ void MarkAddr (unsigned Addr, attr_t Attr)
 
     /* We must not have more than one style bit */
     if (Attr & atStyleMask) {
-       if (AttrTab[Addr] & atStyleMask) {
-           Error ("Duplicate style for address %04X", Addr);
-       }
+        if (AttrTab[Addr] & atStyleMask) {
+            Error ("Duplicate style for address %04X", Addr);
+        }
     }
 
     /* Set the style */
@@ -154,6 +182,3 @@ attr_t GetLabelAttr (unsigned Addr)
     /* Return the attribute */
     return (AttrTab[Addr] & atLabelMask);
 }
-
-
-