6 static const char *_findMapping(const char *szKey)
8 return shash_find(_h, szKey);
11 static va_list _iprintf(char *pInto, const char *szFormat, va_list ap)
14 char *sz = gc_strdup(szFormat);
19 /* See if it's a special emitter */
25 /* Scan out the arg and pass it on to sprintf */
32 vsprintf(pInto, p, ap);
33 /* PENDING: Assume that the arg length was an int */
38 pInto = pStart + strlen(pStart);
49 void tvsprintf(char *buffer, const char *szFormat, va_list ap)
51 char *sz = gc_strdup(szFormat);
52 char *pInto = buffer, *p;
58 /* Start of a token. Search until the first
59 [non alplha, *] and call it a token. */
63 while (isalpha(*sz) || *sz == '*') {
68 /* Now find the token in the token list */
69 if ((t = _findMapping(p))) {
70 ap = _iprintf(pInto, t, ap);
71 pInto = buffer + strlen(buffer);
74 fprintf(stderr, "Cant find token \"%s\"\n", p);
79 else if (*sz == '%') {
88 vsprintf(pInto, pFormat, ap);
89 pInto = buffer + strlen(buffer);
100 void tfprintf(FILE *fp, const char *szFormat, ...)
103 char buffer[MAX_INLINEASM];
105 va_start(ap, szFormat);
106 tvsprintf(buffer, szFormat, ap);
110 void tsprintf(char *buffer, const char *szFormat, ...)
113 va_start(ap, szFormat);
114 tvsprintf(buffer, szFormat, ap);
117 void asm_addTree(const ASM_MAPPINGS *pMappings)
119 const ASM_MAPPING *pMap;
120 /* Traverse down first */
121 if (pMappings->pParent)
122 asm_addTree(pMappings->pParent);
123 pMap = pMappings->pMappings;
124 while (pMap->szKey && pMap->szValue) {
125 shash_add(&_h, pMap->szKey, pMap->szValue);
130 static const ASM_MAPPING _asxxxx_mapping[] = {
131 { "labeldef", "%s::" },
132 { "tlabeldef", "%05d$:" },
133 { "tlabel", "%05d$" },
137 { "area", ".area %s" },
138 { "areacode", ".area %s" },
139 { "areadata", ".area %s" },
140 { "ascii", ".ascii \"%s\"" },
146 { "constbyte", "0x%02X" },
147 { "constword", "0x%04X" },
148 { "immedword", "#0x%04X" },
149 { "immedbyte", "#0x%02X" },
150 { "hashedstr", "#%s" },
151 { "lsbimmeds", "#<%s" },
152 { "msbimmeds", "#>%s" },
153 { "module", ".module %s" },
154 { "global", ".globl %s" },
155 { "fileprelude", "" },
157 "; ---------------------------------\n"
159 "; ---------------------------------"
161 { "functionlabeldef", "%s:" },
165 const ASM_MAPPINGS asm_asxxxx_mapping = {