1 /*****************************************************************************/
5 /* Disassembler attribute table */
9 /* (C) 2000-2006 Ullrich von Bassewitz */
10 /* Römerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
42 /*****************************************************************************/
44 /*****************************************************************************/
49 static unsigned short AttrTab[0x10000];
53 /*****************************************************************************/
55 /*****************************************************************************/
59 void AddrCheck (unsigned Addr)
60 /* Check if the given address has a valid range */
62 if (Addr >= 0x10000) {
63 Error ("Address out of range: %08X", Addr);
69 unsigned GetGranularity (attr_t Style)
70 /* Get the granularity for the given style */
73 case atDefault: return 1;
74 case atCode: return 1;
75 case atIllegal: return 1;
76 case atByteTab: return 1;
77 case atDByteTab: return 2;
78 case atWordTab: return 2;
79 case atDWordTab: return 4;
80 case atAddrTab: return 2;
81 case atRtsTab: return 2;
82 case atTextTab: return 1;
86 Internal ("GetGraularity called for style = %d", Style);
93 void MarkRange (unsigned Start, unsigned End, attr_t Attr)
94 /* Mark a range with the given attribute */
96 /* Do it easy here... */
97 while (Start <= End) {
98 MarkAddr (Start++, Attr);
104 void MarkAddr (unsigned Addr, attr_t Attr)
105 /* Mark an address with an attribute */
107 /* Check the given address */
110 /* We must not have more than one style bit */
111 if (Attr & atStyleMask) {
112 if (AttrTab[Addr] & atStyleMask) {
113 Error ("Duplicate style for address %04X", Addr);
118 AttrTab[Addr] |= Attr;
123 attr_t GetStyleAttr (unsigned Addr)
124 /* Return the style attribute for the given address */
126 /* Check the given address */
129 /* Return the attribute */
130 return (AttrTab[Addr] & atStyleMask);
135 attr_t GetLabelAttr (unsigned Addr)
136 /* Return the label attribute for the given address */
138 /* Check the given address */
141 /* Return the attribute */
142 return (AttrTab[Addr] & atLabelMask);