1 /*****************************************************************************/
5 /* Additional information about 6502 code */
9 /* (C) 2001 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
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 /*****************************************************************************/
44 /*****************************************************************************/
46 /*****************************************************************************/
50 /* Table listing the function names and code info values for known internally
51 * used functions. This table should get auto-generated in the future.
53 typedef struct FuncInfo FuncInfo;
55 const char* Name; /* Function name */
56 unsigned char Use; /* Register usage */
57 unsigned char Chg; /* Changed/destroyed registers */
60 static const FuncInfo FuncInfoTable[] = {
61 { "booleq", REG_NONE, REG_AX },
62 { "boolge", REG_NONE, REG_AX },
63 { "boolgt", REG_NONE, REG_AX },
64 { "boolle", REG_NONE, REG_AX },
65 { "boollt", REG_NONE, REG_AX },
66 { "boolne", REG_NONE, REG_AX },
67 { "booluge", REG_NONE, REG_AX },
68 { "boolugt", REG_NONE, REG_AX },
69 { "boolule", REG_NONE, REG_AX },
70 { "boolult", REG_NONE, REG_AX },
71 { "decax1", REG_AX, REG_AX },
72 { "decax2", REG_AX, REG_AX },
73 { "decax3", REG_AX, REG_AX },
74 { "decax4", REG_AX, REG_AX },
75 { "decax5", REG_AX, REG_AX },
76 { "decax6", REG_AX, REG_AX },
77 { "decax7", REG_AX, REG_AX },
78 { "decax8", REG_AX, REG_AX },
79 { "decaxy", REG_AXY, REG_AX },
80 { "decsp2", REG_NONE, REG_A },
81 { "decsp3", REG_NONE, REG_A },
82 { "decsp4", REG_NONE, REG_A },
83 { "decsp5", REG_NONE, REG_A },
84 { "decsp6", REG_NONE, REG_A },
85 { "decsp7", REG_NONE, REG_A },
86 { "decsp8", REG_NONE, REG_A },
87 { "ldax0sp", REG_Y, REG_AX },
88 { "ldaxysp", REG_Y, REG_AX },
89 { "pusha", REG_A, REG_Y },
90 { "pusha0", REG_A, REG_XY },
91 { "pushax", REG_AX, REG_Y },
92 { "pushw0sp", REG_NONE, REG_AXY },
93 { "pushwysp", REG_Y, REG_AXY },
94 { "tosicmp", REG_AX, REG_AXY },
96 #define FuncInfoCount (sizeof(FuncInfoTable) / sizeof(FuncInfoTable[0]))
100 /*****************************************************************************/
102 /*****************************************************************************/
106 static int CompareFuncInfo (const void* Key, const void* Info)
107 /* Compare function for bsearch */
109 return strcmp (Key, ((const FuncInfo*) Info)->Name);
114 void GetFuncInfo (const char* Name, unsigned char* Use, unsigned char* Chg)
115 /* For the given function, lookup register information and combine it with
116 * the information already in place. If the function is unknown, assume it
117 * will use all registers and load all registers.
118 * See codeinfo.h for possible flags.
121 /* Search for the function */
122 const FuncInfo* Info = bsearch (Name, FuncInfoTable, FuncInfoCount,
123 sizeof(FuncInfo), CompareFuncInfo);
125 /* Do we know the function? */
127 /* Use the information we have */