| 1 | /* |
| 2 | the DASM macro assembler (aka small systems cross assembler) |
| 3 | |
| 4 | Copyright (c) 1988-2002 by Matthew Dillon. |
| 5 | Copyright (c) 1995 by Olaf "Rhialto" Seibert. |
| 6 | Copyright (c) 2003-2008 by Andrew Davie. |
| 7 | Copyright (c) 2008 by Peter H. Froehlich. |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the terms of the GNU General Public License as published by |
| 11 | the Free Software Foundation; either version 2 of the License, or |
| 12 | (at your option) any later version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License along |
| 20 | with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * MAIN.C |
| 26 | * DASM sourcefile |
| 27 | * NOTE: must handle mnemonic extensions and expression decode/compare. |
| 28 | */ |
| 29 | |
| 30 | #include <strings.h> |
| 31 | #include <unistd.h> |
| 32 | |
| 33 | #include "version.h"cxx . . $ `<file>/src/version.h`/ |
| 34 | #include "asm.h"cxx . . $ `<file>/src/asm.h`/ |
| 35 | |
| 36 | static const char dasm_idcxx . . $ dasm_id.[] = DASM_IDcxx . . $ `src/version.h:40:9`!; |
| 37 | |
| 38 | #define ISEGNAMEcxx . . $ `src/main.c:38:9`! "INITIAL CODE SEGMENT" |
| 39 | |
| 40 | /* |
| 41 | replace old atoi() calls; I wanted to protect this using |
| 42 | #ifdef strtol but the C preprocessor doesn't recognize |
| 43 | function names, at least not GCC's; we should be safe |
| 44 | since MS compilers document strtol as well... [phf] |
| 45 | */ |
| 46 | #define atoicxx . . $ `src/main.c:46:9`!(x) ((int)strtol(x, (char **)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10)) |
| 47 | |
| 48 | static const char *cleanupcxx . . $ cleanup(d2bc64eaa2e6f7db).(char *buf, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bDisable); |
| 49 | |
| 50 | MNEMONICcxx . . $ `src/asm.h:154:9`! *parsecxx . . $ parse(4e299f1ac3401714).(char *buf); |
| 51 | void paniccxx . . $ panic(85c52e162fed56f9).(const char *str); |
| 52 | MNEMONICcxx . . $ `src/asm.h:154:9`! *findmnecxx . . $ findmne(4e299f1ac3401714).(char *str); |
| 53 | void clearsegscxx . . $ clearsegs(49f6e7a06ebc5aa8).(void); |
| 54 | void clearrefscxx . . $ clearrefs(49f6e7a06ebc5aa8).(void); |
| 55 | |
| 56 | static unsigned int hash1cxx . . $ hash1(c61c63047ce273de).(const char *str); |
| 57 | static void outlistfilecxx . . $ outlistfile(85c52e162fed56f9).(const char *); |
| 58 | |
| 59 | // buffers to supress errors and messages until last pass |
| 60 | char *passbuffercxx . . $ passbuffer. [2] = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!}; |
| 61 | #define ERRORBUFcxx . . $ `src/main.c:61:9`! 0 |
| 62 | #define MSGBUFcxx . . $ `src/main.c:62:9`! 1 |
| 63 | void passbuffer_clearcxx . . $ passbuffer_clear(d4f767463ce0a6b3).(int); |
| 64 | void passbuffer_updatecxx . . $ passbuffer_update(577809987ad7a468).(int,char *); |
| 65 | void passbuffer_outputcxx . . $ passbuffer_output(d4f767463ce0a6b3).(int); |
| 66 | void passbuffer_cleanupcxx . . $ passbuffer_cleanup(49f6e7a06ebc5aa8).(void); |
| 67 | |
| 68 | int mlflagcxx . . $ mlflag. = 0; // multi-line comments |
| 69 | |
| 70 | static char erroradd1cxx . . $ erroradd1.[500]; // temp error holders |
| 71 | static char erroradd2cxx . . $ erroradd2.[500]; |
| 72 | static char erroradd3cxx . . $ erroradd3.[500]; |
| 73 | |
| 74 | /* Table encapsulates errors, descriptions, and fatality flags. */ |
| 75 | |
| 76 | ERROR_DEFINITIONcxx . . $ ERROR_DEFINITION# sErrorDefcxx . . $ sErrorDef.[] = { |
| 77 | |
| 78 | /* Error #, STOPEND, Description */ |
| 79 | |
| 80 | { ERROR_NONEcxx . . $ ERROR_NONE., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "OK" }, |
| 81 | { ERROR_COMMAND_LINEcxx . . $ ERROR_COMMAND_LINE., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Check command-line format." }, |
| 82 | { ERROR_FILE_ERRORcxx . . $ ERROR_FILE_ERROR., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Unable to open file." }, |
| 83 | { ERROR_NOT_RESOLVABLEcxx . . $ ERROR_NOT_RESOLVABLE., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Source is not resolvable." }, |
| 84 | { ERROR_TOO_MANY_PASSEScxx . . $ ERROR_TOO_MANY_PASSES., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Too many passes (%s)." }, |
| 85 | { ERROR_NON_ABORTcxx . . $ ERROR_NON_ABORT., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "See previous output" }, |
| 86 | { ERROR_SYNTAX_ERRORcxx . . $ ERROR_SYNTAX_ERROR., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Syntax Error '%s'." }, |
| 87 | { ERROR_EXPRESSION_TABLE_OVERFLOWcxx . . $ ERROR_EXPRESSION_TABLE_OVERFLOW., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Expression table overflow." }, |
| 88 | { ERROR_UNBALANCED_BRACEScxx . . $ ERROR_UNBALANCED_BRACES., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Unbalanced Braces []." }, |
| 89 | { ERROR_DIVISION_BY_0cxx . . $ ERROR_DIVISION_BY_0., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Division by zero." }, |
| 90 | { ERROR_UNKNOWN_MNEMONICcxx . . $ ERROR_UNKNOWN_MNEMONIC., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Unknown Mnemonic '%s'." }, |
| 91 | { ERROR_ILLEGAL_ADDRESSING_MODEcxx . . $ ERROR_ILLEGAL_ADDRESSING_MODE., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "Illegal Addressing mode '%s'." }, |
| 92 | { ERROR_ILLEGAL_FORCED_ADDRESSING_MODEcxx . . $ ERROR_ILLEGAL_FORCED_ADDRESSING_MODE., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Illegal forced Addressing mode on '%s'." }, |
| 93 | { ERROR_NOT_ENOUGH_ARGUMENTS_PASSED_TO_MACROcxx . . $ ERROR_NOT_ENOUGH_ARGUMENTS_PASSED_TO_MACRO., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Not enough args passed to Macro." }, |
| 94 | { ERROR_PREMATURE_EOFcxx . . $ ERROR_PREMATURE_EOF., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "Premature EOF." }, |
| 95 | { ERROR_ILLEGAL_CHARACTERcxx . . $ ERROR_ILLEGAL_CHARACTER., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Illegal character '%s'." }, |
| 96 | { ERROR_BRANCH_OUT_OF_RANGEcxx . . $ ERROR_BRANCH_OUT_OF_RANGE., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "Branch out of range (%s bytes)." }, |
| 97 | { ERROR_ERR_PSEUDO_OP_ENCOUNTEREDcxx . . $ ERROR_ERR_PSEUDO_OP_ENCOUNTERED., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "ERR pseudo-op encountered." }, |
| 98 | { ERROR_ORIGIN_REVERSE_INDEXEDcxx . . $ ERROR_ORIGIN_REVERSE_INDEXED., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "Origin Reverse-indexed." }, |
| 99 | { ERROR_EQU_VALUE_MISMATCHcxx . . $ ERROR_EQU_VALUE_MISMATCH., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "EQU: Value mismatch." }, |
| 100 | { ERROR_ADDRESS_MUST_BE_LT_100cxx . . $ ERROR_ADDRESS_MUST_BE_LT_100., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Value in '%s' must be <$100." }, |
| 101 | { ERROR_ADDRESS_MUST_BE_LT_10000cxx . . $ ERROR_ADDRESS_MUST_BE_LT_10000., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Value in '%s' must be <$10000." }, |
| 102 | { ERROR_ILLEGAL_BIT_SPECIFICATIONcxx . . $ ERROR_ILLEGAL_BIT_SPECIFICATION., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Illegal bit specification." }, |
| 103 | { ERROR_NOT_ENOUGH_ARGScxx . . $ ERROR_NOT_ENOUGH_ARGS., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Not enough arguments." }, |
| 104 | { ERROR_LABEL_MISMATCHcxx . . $ ERROR_LABEL_MISMATCH., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "Label mismatch...\n --> %s" }, |
| 105 | { ERROR_MACRO_REPEATEDcxx . . $ ERROR_MACRO_REPEATED., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Macro \"%s\" definition is repeated." }, |
| 106 | { ERROR_VALUE_UNDEFINEDcxx . . $ ERROR_VALUE_UNDEFINED., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Value Undefined." }, |
| 107 | { ERROR_PROCESSOR_NOT_SUPPORTEDcxx . . $ ERROR_PROCESSOR_NOT_SUPPORTED., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Processor '%s' not supported." }, |
| 108 | { ERROR_REPEAT_NEGATIVEcxx . . $ ERROR_REPEAT_NEGATIVE., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, "REPEAT parameter < 0 (ignored)." }, |
| 109 | { ERROR_BADERRORcxx . . $ ERROR_BADERROR., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Bad error value (internal error)." }, |
| 110 | { ERROR_ONLY_ONE_PROCESSOR_SUPPORTEDcxx . . $ ERROR_ONLY_ONE_PROCESSOR_SUPPORTED., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Only one processor type may be selected." }, |
| 111 | { ERROR_BAD_FORMATcxx . . $ ERROR_BAD_FORMAT., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Bad output format specified." }, |
| 112 | { ERROR_VALUE_MUST_BE_1_OR_4cxx . . $ ERROR_VALUE_MUST_BE_1_OR_4., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Value in '%s' must be 1 or 4." }, |
| 113 | { ERROR_VALUE_MUST_BE_LT_10cxx . . $ ERROR_VALUE_MUST_BE_LT_10., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Value in '%s' must be <$10." }, |
| 114 | { ERROR_VALUE_MUST_BE_LT_8cxx . . $ ERROR_VALUE_MUST_BE_LT_8., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Value in '%s' must be <$8." }, |
| 115 | { ERROR_VALUE_MUST_BE_LT_Fcxx . . $ ERROR_VALUE_MUST_BE_LT_F., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Value in '%s' must be <$f." }, |
| 116 | { ERROR_VALUE_MUST_BE_LT_10000cxx . . $ ERROR_VALUE_MUST_BE_LT_10000., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Value in '%s' must be <$10000." }, |
| 117 | { ERROR_ILLEGAL_OPERAND_COMBINATIONcxx . . $ ERROR_ILLEGAL_OPERAND_COMBINATION., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Illegal combination of operands '%s'" }, |
| 118 | { ERROR_RECURSION_TOO_DEEPcxx . . $ ERROR_RECURSION_TOO_DEEP., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Recursion too deep in %s" }, |
| 119 | { ERROR_AVOID_SEGFAULTcxx . . $ ERROR_AVOID_SEGFAULT., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Internal error in %s" }, |
| 120 | { ERROR_MISSING_ENDMcxx . . $ ERROR_MISSING_ENDM., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Unbalanced macro %s" }, |
| 121 | { ERROR_MISSING_COMMENT_ENDcxx . . $ ERROR_MISSING_COMMENT_END., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Multi-line comment not closed." }, |
| 122 | { ERROR_SPURIOUS_COMMENT_CLOSEcxx . . $ ERROR_SPURIOUS_COMMENT_CLOSE., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Multi-line comment closed without open." }, |
| 123 | {-1, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Doh! Internal end-of-table marker, report the bug!"} |
| 124 | }; |
| 125 | |
| 126 | #define MAX_ERRORcxx . . $ `src/main.c:126:9`! (( sizeof( sErrorDef ) / sizeof( ERROR_DEFINITION ))) |
| 127 | |
| 128 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! *bStopAtEndcxx . . $ bStopAtEnd.; |
| 129 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bRemoveOutBincxx . . $ bRemoveOutBin. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 130 | |
| 131 | int nMaxPassescxx . . $ nMaxPasses. = 10; |
| 132 | |
| 133 | char *Extstrcxx . . $ Extstr.; |
| 134 | /*unsigned char Listing = 1;*/ |
| 135 | |
| 136 | int passcxx . . $ pass.; |
| 137 | |
| 138 | unsigned char F_ListAllPassescxx . . $ F_ListAllPasses. = 0; |
| 139 | |
| 140 | static int CountUnresolvedSymbolscxx . . $ CountUnresolvedSymbols(b126dc7c1de90089).(void) |
| 141 | { |
| 142 | SYMBOLcxx . . $ `src/asm.h:160:9`! *sym; |
| 143 | int nUnresolved = 0; |
| 144 | int i; |
| 145 | |
| 146 | /* Pre-count unresolved symbols */ |
| 147 | for (i = 0; i < SHASHSIZEcxx . . $ `src/asm.h:165:9`!; ++i) |
| 148 | for (sym = SHashcxx . . $ SHash.[i]; sym; sym = sym->nextcxx . . $ _SYMBOL#next.) |
| 149 | if ( sym->flagscxx . . $ _SYMBOL#flags. & SYM_UNKNOWNcxx . . $ `src/asm.h:326:9`! ) |
| 150 | nUnresolved++; |
| 151 | |
| 152 | return nUnresolved; |
| 153 | } |
| 154 | |
| 155 | |
| 156 | static int ShowUnresolvedSymbolscxx . . $ ShowUnresolvedSymbols(b126dc7c1de90089).(void) |
| 157 | { |
| 158 | SYMBOLcxx . . $ `src/asm.h:160:9`! *sym; |
| 159 | int i; |
| 160 | |
| 161 | int nUnresolved = CountUnresolvedSymbolscxx . . $ CountUnresolvedSymbols(b126dc7c1de90089).(); |
| 162 | if ( nUnresolved ) |
| 163 | { |
| 164 | printfcxx . . $ printf(581fddd72a8db8fc).( "--- Unresolved Symbol List\n" ); |
| 165 | |
| 166 | /* Display unresolved symbols */ |
| 167 | for (i = 0; i < SHASHSIZEcxx . . $ `src/asm.h:165:9`!; ++i) |
| 168 | for (sym = SHashcxx . . $ SHash.[i]; sym; sym = sym->nextcxx . . $ _SYMBOL#next.) |
| 169 | if ( sym->flagscxx . . $ _SYMBOL#flags. & SYM_UNKNOWNcxx . . $ `src/asm.h:326:9`! ) |
| 170 | printfcxx . . $ printf(581fddd72a8db8fc).( "%-24s %s\n", sym->namecxx . . $ _SYMBOL#name., sftoscxx . . $ sftos(ef4cfbd1f56d9042).( sym->valuecxx . . $ _SYMBOL#value., sym->flagscxx . . $ _SYMBOL#flags. ) ); |
| 171 | |
| 172 | printfcxx . . $ printf(581fddd72a8db8fc).( "--- %d Unresolved Symbol%c\n\n", nUnresolved, ( nUnresolved == 1 ) ? ' ' : 's' ); |
| 173 | } |
| 174 | |
| 175 | return nUnresolved; |
| 176 | } |
| 177 | |
| 178 | |
| 179 | static int CompareAlphacxx . . $ CompareAlpha(9148c8c3ff42c9d8).( const void *arg1, const void *arg2 ) |
| 180 | { |
| 181 | /* Simple alphabetic ordering comparison function for quicksort */ |
| 182 | |
| 183 | const SYMBOLcxx . . $ `src/asm.h:160:9`! *sym1 = *(SYMBOLcxx . . $ `src/asm.h:160:9`! * const *) arg1; |
| 184 | const SYMBOLcxx . . $ `src/asm.h:160:9`! *sym2 = *(SYMBOLcxx . . $ `src/asm.h:160:9`! * const *) arg2; |
| 185 | |
| 186 | /* |
| 187 | The cast above is wild, thank goodness the Linux man page |
| 188 | for qsort(3) has an example explaining it... :-) [phf] |
| 189 | |
| 190 | TODO: Note that we compare labels case-insensitive here which |
| 191 | is not quite right; I believe we should be case-sensitive as |
| 192 | in other contexts where symbols (labels) are compared. But |
| 193 | the old CompareAlpha() was case-insensitive as well, so I |
| 194 | didn't want to change that right now... [phf] |
| 195 | */ |
| 196 | |
| 197 | return strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(sym1->namecxx . . $ _SYMBOL#name., sym2->namecxx . . $ _SYMBOL#name.); |
| 198 | } |
| 199 | |
| 200 | static int CompareAddresscxx . . $ CompareAddress(9148c8c3ff42c9d8).( const void *arg1, const void *arg2 ) |
| 201 | { |
| 202 | /* Simple numeric ordering comparison function for quicksort */ |
| 203 | |
| 204 | const SYMBOLcxx . . $ `src/asm.h:160:9`! *sym1 = *(SYMBOLcxx . . $ `src/asm.h:160:9`! * const *) arg1; |
| 205 | const SYMBOLcxx . . $ `src/asm.h:160:9`! *sym2 = *(SYMBOLcxx . . $ `src/asm.h:160:9`! * const *) arg2; |
| 206 | |
| 207 | return sym1->valuecxx . . $ _SYMBOL#value. - sym2->valuecxx . . $ _SYMBOL#value.; |
| 208 | } |
| 209 | |
| 210 | /* bTableSort true -> by address, false -> by name [phf] */ |
| 211 | static void ShowSymbolscxx . . $ ShowSymbols(830a66354e950082).( FILEcxx . . $ FILE# *file, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bTableSort ) |
| 212 | { |
| 213 | /* Display sorted (!) symbol table - if it runs out of memory, table will be displayed unsorted */ |
| 214 | |
| 215 | SYMBOLcxx . . $ `src/asm.h:160:9`! **symArray; |
| 216 | SYMBOLcxx . . $ `src/asm.h:160:9`! *sym; |
| 217 | int i; |
| 218 | int nSymbols = 0; |
| 219 | |
| 220 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).( file, "--- Symbol List"); |
| 221 | |
| 222 | /* Sort the symbol list either via name, or by value */ |
| 223 | |
| 224 | /* First count the number of symbols */ |
| 225 | for (i = 0; i < SHASHSIZEcxx . . $ `src/asm.h:165:9`!; ++i) |
| 226 | for (sym = SHashcxx . . $ SHash.[i]; sym; sym = sym->nextcxx . . $ _SYMBOL#next.) |
| 227 | nSymbols++; |
| 228 | |
| 229 | /* Malloc an array of pointers to data */ |
| 230 | |
| 231 | symArray = (SYMBOLcxx . . $ `src/asm.h:160:9`! **)ckmalloccxx . . $ ckmalloc(ff224f080444ee45).( sizeof( SYMBOLcxx . . $ `src/asm.h:160:9`! * ) * nSymbols ); |
| 232 | if ( !symArray ) |
| 233 | { |
| 234 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).( file, " (unsorted - not enough memory to sort!)\n" ); |
| 235 | |
| 236 | /* Display complete symbol table */ |
| 237 | for (i = 0; i < SHASHSIZEcxx . . $ `src/asm.h:165:9`!; ++i) |
| 238 | for (sym = SHashcxx . . $ SHash.[i]; sym; sym = sym->nextcxx . . $ _SYMBOL#next.) |
| 239 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).( file, "%-24s %s\n", sym->namecxx . . $ _SYMBOL#name., sftoscxx . . $ sftos(ef4cfbd1f56d9042).( sym->valuecxx . . $ _SYMBOL#value., sym->flagscxx . . $ _SYMBOL#flags. ) ); |
| 240 | } |
| 241 | else |
| 242 | { |
| 243 | /* Copy the element pointers into the symbol array */ |
| 244 | |
| 245 | int nPtr = 0; |
| 246 | |
| 247 | for (i = 0; i < SHASHSIZEcxx . . $ `src/asm.h:165:9`!; ++i) |
| 248 | for (sym = SHashcxx . . $ SHash.[i]; sym; sym = sym->nextcxx . . $ _SYMBOL#next.) |
| 249 | symArray[ nPtr++ ] = sym; |
| 250 | |
| 251 | if ( bTableSort ) |
| 252 | { |
| 253 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).( file, " (sorted by address)\n" ); |
| 254 | qsortcxx . . $ qsort(ebb60b13a65e77d7).( symArray, nPtr, sizeof( SYMBOLcxx . . $ `src/asm.h:160:9`! * ), CompareAddresscxx . . $ CompareAddress(9148c8c3ff42c9d8). ); /* Sort via address */ |
| 255 | } |
| 256 | else |
| 257 | { |
| 258 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).( file, " (sorted by symbol)\n" ); |
| 259 | qsortcxx . . $ qsort(ebb60b13a65e77d7).( symArray, nPtr, sizeof( SYMBOLcxx . . $ `src/asm.h:160:9`! * ), CompareAlphacxx . . $ CompareAlpha(9148c8c3ff42c9d8). ); /* Sort via name */ |
| 260 | } |
| 261 | |
| 262 | |
| 263 | /* now display sorted list */ |
| 264 | |
| 265 | for ( i = 0; i < nPtr; i++ ) |
| 266 | { |
| 267 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).( file, "%-24s %-12s", symArray[ i ]->namecxx . . $ _SYMBOL#name., |
| 268 | sftoscxx . . $ sftos(ef4cfbd1f56d9042).( symArray[ i ]->valuecxx . . $ _SYMBOL#value., symArray[ i ]->flagscxx . . $ _SYMBOL#flags. ) ); |
| 269 | if ( symArray[ i ]->flagscxx . . $ _SYMBOL#flags. & SYM_STRINGcxx . . $ `src/asm.h:328:9`! ) |
| 270 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).( file, " \"%s\"", symArray[ i ]->stringcxx . . $ _SYMBOL#string. ); /* If a string, display actual string */ |
| 271 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).( file, "\n" ); |
| 272 | } |
| 273 | |
| 274 | freecxx . . $ free(5d22bdacc48458e8).( symArray ); |
| 275 | } |
| 276 | |
| 277 | fputscxx . . $ fputs(874fa6a5e59ab9bd).( "--- End of Symbol List.\n", file ); |
| 278 | |
| 279 | } |
| 280 | |
| 281 | |
| 282 | |
| 283 | static void ShowSegmentscxx . . $ ShowSegments(49f6e7a06ebc5aa8).(void) |
| 284 | { |
| 285 | SEGMENTcxx . . $ `src/asm.h:159:9`! *seg; |
| 286 | const char *bss; |
| 287 | const char *sFormat = "%-24s %-3s %-8s %-8s %-8s %-8s\n\0"; |
| 288 | |
| 289 | |
| 290 | |
| 291 | printfcxx . . $ printf(581fddd72a8db8fc).("\n----------------------------------------------------------------------\n"); |
| 292 | printfcxx . . $ printf(581fddd72a8db8fc).( sFormat, "SEGMENT NAME", "", "INIT PC", "INIT RPC", "FINAL PC", "FINAL RPC" ); |
| 293 | |
| 294 | for (seg = Seglistcxx . . $ Seglist.; seg; seg = seg->nextcxx . . $ _SEGMENT#next.) |
| 295 | { |
| 296 | bss = (seg->flagscxx . . $ _SEGMENT#flags. & SF_BSScxx . . $ `src/asm.h:310:9`!) ? "[u]" : " "; |
| 297 | |
| 298 | printfcxx . . $ printf(581fddd72a8db8fc).( sFormat, seg->namecxx . . $ _SEGMENT#name., bss, |
| 299 | sftoscxx . . $ sftos(ef4cfbd1f56d9042).(seg->initorgcxx . . $ _SEGMENT#initorg., seg->initflagscxx . . $ _SEGMENT#initflags.), sftoscxx . . $ sftos(ef4cfbd1f56d9042).(seg->initrorgcxx . . $ _SEGMENT#initrorg., seg->initrflagscxx . . $ _SEGMENT#initrflags.), |
| 300 | sftoscxx . . $ sftos(ef4cfbd1f56d9042).(seg->orgcxx . . $ _SEGMENT#org., seg->flagscxx . . $ _SEGMENT#flags.), sftoscxx . . $ sftos(ef4cfbd1f56d9042).(seg->rorgcxx . . $ _SEGMENT#rorg., seg->rflagscxx . . $ _SEGMENT#rflags.) ); |
| 301 | } |
| 302 | putscxx . . $ puts(5c4306d8553b3696).("----------------------------------------------------------------------"); |
| 303 | |
| 304 | printfcxx . . $ printf(581fddd72a8db8fc).( "%d references to unknown symbols.\n", Redo_evalcxx . . $ Redo_eval. ); |
| 305 | printfcxx . . $ printf(581fddd72a8db8fc).( "%d events requiring another assembler pass.\n", Redocxx . . $ Redo. ); |
| 306 | |
| 307 | if ( Redo_whycxx . . $ Redo_why. ) |
| 308 | { |
| 309 | if ( Redo_whycxx . . $ Redo_why. & REASON_MNEMONIC_NOT_RESOLVEDcxx . . $ REASON_MNEMONIC_NOT_RESOLVED. ) |
| 310 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Expression in mnemonic not resolved.\n" ); |
| 311 | |
| 312 | if ( Redo_whycxx . . $ Redo_why. & REASON_OBSCUREcxx . . $ REASON_OBSCURE. ) |
| 313 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Obscure reason - to be documented :)\n" ); |
| 314 | |
| 315 | if ( Redo_whycxx . . $ Redo_why. & REASON_DC_NOT_RESOVEDcxx . . $ REASON_DC_NOT_RESOVED. ) |
| 316 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Expression in a DC not resolved.\n" ); |
| 317 | |
| 318 | if ( Redo_whycxx . . $ Redo_why. & REASON_DV_NOT_RESOLVED_PROBABLYcxx . . $ REASON_DV_NOT_RESOLVED_PROBABLY. ) |
| 319 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Expression in a DV not resolved (probably in DV's EQM symbol).\n" ); |
| 320 | |
| 321 | if ( Redo_whycxx . . $ Redo_why. & REASON_DV_NOT_RESOLVED_COULDcxx . . $ REASON_DV_NOT_RESOLVED_COULD. ) |
| 322 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Expression in a DV not resolved (could be in DV's EQM symbol).\n" ); |
| 323 | |
| 324 | if ( Redo_whycxx . . $ Redo_why. & REASON_DS_NOT_RESOLVEDcxx . . $ REASON_DS_NOT_RESOLVED. ) |
| 325 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Expression in a DS not resolved.\n" ); |
| 326 | |
| 327 | if ( Redo_whycxx . . $ Redo_why. & REASON_ALIGN_NOT_RESOLVEDcxx . . $ REASON_ALIGN_NOT_RESOLVED. ) |
| 328 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Expression in an ALIGN not resolved.\n" ); |
| 329 | |
| 330 | if ( Redo_whycxx . . $ Redo_why. & REASON_ALIGN_RELOCATABLE_ORIGIN_NOT_KNOWNcxx . . $ REASON_ALIGN_RELOCATABLE_ORIGIN_NOT_KNOWN. ) |
| 331 | printfcxx . . $ printf(581fddd72a8db8fc).( " - ALIGN: Relocatable origin not known (if in RORG at the time).\n" ); |
| 332 | |
| 333 | if ( Redo_whycxx . . $ Redo_why. & REASON_ALIGN_NORMAL_ORIGIN_NOT_KNOWNcxx . . $ REASON_ALIGN_NORMAL_ORIGIN_NOT_KNOWN. ) |
| 334 | printfcxx . . $ printf(581fddd72a8db8fc).( " - ALIGN: Normal origin not known (if in ORG at the time).\n" ); |
| 335 | |
| 336 | if ( Redo_whycxx . . $ Redo_why. & REASON_EQU_NOT_RESOLVEDcxx . . $ REASON_EQU_NOT_RESOLVED. ) |
| 337 | printfcxx . . $ printf(581fddd72a8db8fc).( " - EQU: Expression not resolved.\n" ); |
| 338 | |
| 339 | if ( Redo_whycxx . . $ Redo_why. & REASON_EQU_VALUE_MISMATCHcxx . . $ REASON_EQU_VALUE_MISMATCH. ) |
| 340 | printfcxx . . $ printf(581fddd72a8db8fc).( " - EQU: Value mismatch from previous pass (phase error).\n" ); |
| 341 | |
| 342 | if ( Redo_whycxx . . $ Redo_why. & REASON_IF_NOT_RESOLVEDcxx . . $ REASON_IF_NOT_RESOLVED. ) |
| 343 | printfcxx . . $ printf(581fddd72a8db8fc).( " - IF: Expression not resolved.\n" ); |
| 344 | |
| 345 | if ( Redo_whycxx . . $ Redo_why. & REASON_REPEAT_NOT_RESOLVEDcxx . . $ REASON_REPEAT_NOT_RESOLVED. ) |
| 346 | printfcxx . . $ printf(581fddd72a8db8fc).( " - REPEAT: Expression not resolved.\n" ); |
| 347 | |
| 348 | if ( Redo_whycxx . . $ Redo_why. & REASON_FORWARD_REFERENCEcxx . . $ REASON_FORWARD_REFERENCE. ) |
| 349 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Label defined after it has been referenced (forward reference).\n" ); |
| 350 | |
| 351 | if ( Redo_whycxx . . $ Redo_why. & REASON_PHASE_ERRORcxx . . $ REASON_PHASE_ERROR. ) |
| 352 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Label value is different from that of the previous pass (phase error).\n" ); |
| 353 | |
| 354 | if ( Redo_whycxx . . $ Redo_why. & REASON_BRANCH_OUT_OF_RANGEcxx . . $ REASON_BRANCH_OUT_OF_RANGE. ) |
| 355 | printfcxx . . $ printf(581fddd72a8db8fc).( " - Branch was out of range.\n" ); |
| 356 | } |
| 357 | |
| 358 | printfcxx . . $ printf(581fddd72a8db8fc).( "\n" ); |
| 359 | |
| 360 | } |
| 361 | |
| 362 | |
| 363 | |
| 364 | static void DumpSymbolTablecxx . . $ DumpSymbolTable(b45ddcbc8423892c).( boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bTableSort ) |
| 365 | { |
| 366 | if (F_symfilecxx . . $ F_symfile.) |
| 367 | { |
| 368 | FILEcxx . . $ FILE# *fi = fopencxx . . $ fopen(82ec0787cd37e0a3).(F_symfilecxx . . $ F_symfile., "w"); |
| 369 | if (fi) |
| 370 | { |
| 371 | ShowSymbolscxx . . $ ShowSymbols(830a66354e950082).( fi, bTableSort ); |
| 372 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fi); |
| 373 | } |
| 374 | else |
| 375 | { |
| 376 | printfcxx . . $ printf(581fddd72a8db8fc).("Warning: Unable to open Symbol Dump file '%s'\n", F_symfilecxx . . $ F_symfile.); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | } |
| 381 | |
| 382 | |
| 383 | static int MainShadowcxx . . $ MainShadow(99b3d3d4c05154e4).(int ac, char **av, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! *pbTableSort ) |
| 384 | { |
| 385 | |
| 386 | |
| 387 | |
| 388 | int nError = ERROR_NONEcxx . . $ ERROR_NONE.; |
| 389 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bDoAllPasses = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 390 | |
| 391 | char buf[MAXLINEcxx . . $ `src/asm.h:67:9`!]; |
| 392 | int i; |
| 393 | int argVal; |
| 394 | MNEMONICcxx . . $ `src/asm.h:154:9`! *mne; |
| 395 | |
| 396 | int oldredo = -1; |
| 397 | unsigned long oldwhy = 0; |
| 398 | int oldeval = 0; |
| 399 | |
| 400 | addhashtablecxx . . $ addhashtable(c2a72e93142ff88d).(Opscxx . . $ Ops.); |
| 401 | passcxx . . $ pass. = 1; |
| 402 | |
| 403 | if (ac < 2) |
| 404 | { |
| 405 | |
| 406 | fail: |
| 407 | putscxx . . $ puts(5c4306d8553b3696).(dasm_idcxx . . $ dasm_id.); |
| 408 | putscxx . . $ puts(5c4306d8553b3696).("Copyright (c) 1988-2020 by the DASM team."); |
| 409 | putscxx . . $ puts(5c4306d8553b3696).("License GPLv2+: GNU GPL version 2 or later (see file LICENSE)."); |
| 410 | putscxx . . $ puts(5c4306d8553b3696).("DASM is free software: you are free to change and redistribute it."); |
| 411 | putscxx . . $ puts(5c4306d8553b3696).("There is ABSOLUTELY NO WARRANTY, to the extent permitted by law."); |
| 412 | putscxx . . $ puts(5c4306d8553b3696).(""); |
| 413 | putscxx . . $ puts(5c4306d8553b3696).("Usage: dasm sourcefile [options]"); |
| 414 | putscxx . . $ puts(5c4306d8553b3696).(""); |
| 415 | putscxx . . $ puts(5c4306d8553b3696).("-f# output format 1-3 (default 1)"); |
| 416 | putscxx . . $ puts(5c4306d8553b3696).("-oname output file name (else a.out)"); |
| 417 | putscxx . . $ puts(5c4306d8553b3696).("-lname list file name (else none generated)"); |
| 418 | putscxx . . $ puts(5c4306d8553b3696).("-Lname list file, containing all passes"); |
| 419 | putscxx . . $ puts(5c4306d8553b3696).("-sname symbol dump file name (else none generated)"); |
| 420 | putscxx . . $ puts(5c4306d8553b3696).("-v# verboseness 0-4 (default 0)"); |
| 421 | putscxx . . $ puts(5c4306d8553b3696).("-d debug mode (for developers)"); |
| 422 | putscxx . . $ puts(5c4306d8553b3696).("-Dsymbol define symbol, set to 0"); |
| 423 | putscxx . . $ puts(5c4306d8553b3696).("-Dsymbol=expression define symbol, set to expression"); |
| 424 | putscxx . . $ puts(5c4306d8553b3696).("-Msymbol=expression define symbol using EQM (same as -D)"); |
| 425 | putscxx . . $ puts(5c4306d8553b3696).("-Idir search directory for INCLUDE and INCBIN"); |
| 426 | putscxx . . $ puts(5c4306d8553b3696).("-p# maximum number of passes"); |
| 427 | putscxx . . $ puts(5c4306d8553b3696).("-P# maximum number of passes, with fewer checks"); |
| 428 | putscxx . . $ puts(5c4306d8553b3696).("-T# symbol table sorting (default 0 = alphabetical, 1 = address/value)"); |
| 429 | putscxx . . $ puts(5c4306d8553b3696).("-E# error format (default 0 = MS, 1 = Dillon, 2 = GNU)"); |
| 430 | putscxx . . $ puts(5c4306d8553b3696).("-S strict syntax checking"); |
| 431 | putscxx . . $ puts(5c4306d8553b3696).("-R remove binary output-file in case of errors"); |
| 432 | putscxx . . $ puts(5c4306d8553b3696).("-m# safety barrier to abort on recursions, max. allowed file-size in kB"); |
| 433 | putscxx . . $ puts(5c4306d8553b3696).(""); |
| 434 | putscxx . . $ puts(5c4306d8553b3696).("Report bugs on https://github.com/dasm-assembler/dasm please!"); |
| 435 | |
| 436 | return ERROR_COMMAND_LINEcxx . . $ ERROR_COMMAND_LINE.; |
| 437 | } |
| 438 | |
| 439 | for (i = 2; i < ac; ++i) |
| 440 | { |
| 441 | if ( ( av[i][0] == '-' ) || ( av[i][0] == '/' ) ) |
| 442 | { |
| 443 | char *str = av[i]+2; |
| 444 | switch(av[i][1]) |
| 445 | { |
| 446 | /* TODO: need to improve option parsing and errors for it */ |
| 447 | case 'E': |
| 448 | F_errorformatcxx . . $ F_errorformat. = atoicxx . . $ `src/main.c:46:9`!(str); |
| 449 | if (F_errorformatcxx . . $ F_errorformat. < ERRORFORMAT_DEFAULTcxx . . $ ERRORFORMAT_DEFAULT. |
| 450 | || F_errorformatcxx . . $ F_errorformat. >= ERRORFORMAT_MAXcxx . . $ ERRORFORMAT_MAX. ) |
| 451 | { |
| 452 | paniccxx . . $ panic(85c52e162fed56f9).("Invalid error format for -E, must be 0, 1, 2"); |
| 453 | } |
| 454 | break; |
| 455 | |
| 456 | case 'T': |
| 457 | F_sortmodecxx . . $ F_sortmode. = atoicxx . . $ `src/main.c:46:9`!(str); |
| 458 | if (F_sortmodecxx . . $ F_sortmode. < SORTMODE_DEFAULTcxx . . $ SORTMODE_DEFAULT. |
| 459 | || F_sortmodecxx . . $ F_sortmode. >= SORTMODE_MAXcxx . . $ SORTMODE_MAX. ) |
| 460 | { |
| 461 | paniccxx . . $ panic(85c52e162fed56f9).("Invalid sorting mode for -T option, must be 0 or 1"); |
| 462 | } |
| 463 | /* TODO: refactor into regular configuration [phf] */ |
| 464 | *pbTableSort = (F_sortmodecxx . . $ F_sortmode. != SORTMODE_DEFAULTcxx . . $ SORTMODE_DEFAULT.); |
| 465 | break; |
| 466 | |
| 467 | case 'd': |
| 468 | Xdebugcxx . . $ Xdebug. = atoicxx . . $ `src/main.c:46:9`!(str) != 0; |
| 469 | printfcxx . . $ printf(581fddd72a8db8fc).( "Debug trace %s\n", Xdebugcxx . . $ Xdebug. ? "ON" : "OFF" ); |
| 470 | break; |
| 471 | |
| 472 | case 'M': |
| 473 | case 'D': |
| 474 | while (*str && *str != '=') |
| 475 | ++str; |
| 476 | if (*str == '=') |
| 477 | { |
| 478 | *str = 0; |
| 479 | ++str; |
| 480 | } |
| 481 | else |
| 482 | { |
| 483 | str = "0"; |
| 484 | } |
| 485 | Avcxx . . $ Av.[0] = av[i]+2; |
| 486 | |
| 487 | if (av[i][1] == 'M') |
| 488 | v_eqmcxx . . $ v_eqm(b7f07ba78920e729).(str, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 489 | else |
| 490 | v_setcxx . . $ v_set(b7f07ba78920e729).(str, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 491 | break; |
| 492 | |
| 493 | case 'f': /* F_format */ |
| 494 | F_formatcxx . . $ F_format. = atoicxx . . $ `src/main.c:46:9`!(str); |
| 495 | if (F_formatcxx . . $ F_format. < FORMAT_DEFAULTcxx . . $ FORMAT_DEFAULT. || F_formatcxx . . $ F_format. >= FORMAT_MAXcxx . . $ FORMAT_MAX. ) |
| 496 | paniccxx . . $ panic(85c52e162fed56f9).("Illegal format specification"); |
| 497 | break; |
| 498 | |
| 499 | case 'o': /* F_outfile */ |
| 500 | F_outfilecxx . . $ F_outfile. = str; |
| 501 | nofile: |
| 502 | if (*str == 0) |
| 503 | paniccxx . . $ panic(85c52e162fed56f9).("-o Switch requires file name."); |
| 504 | break; |
| 505 | |
| 506 | case 'L': |
| 507 | F_ListAllPassescxx . . $ F_ListAllPasses. = 1; |
| 508 | /* fall through to 'l' */ |
| 509 | |
| 510 | case 'l': /* F_listfile */ |
| 511 | F_listfilecxx . . $ F_listfile. = str; |
| 512 | goto nofile; |
| 513 | |
| 514 | case 'P': /* F_Passes */ |
| 515 | bDoAllPasses = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 516 | |
| 517 | /* fall through to 'p' */ |
| 518 | case 'p': /* F_passes */ |
| 519 | nMaxPassescxx . . $ nMaxPasses. = atoicxx . . $ `src/main.c:46:9`!(str); |
| 520 | break; |
| 521 | |
| 522 | case 's': /* F_symfile */ |
| 523 | F_symfilecxx . . $ F_symfile. = str; |
| 524 | goto nofile; |
| 525 | case 'v': /* F_verbose */ |
| 526 | F_verbosecxx . . $ F_verbose. = atoicxx . . $ `src/main.c:46:9`!(str); |
| 527 | break; |
| 528 | |
| 529 | case 'I': |
| 530 | v_incdircxx . . $ v_incdir(b7f07ba78920e729).(str, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 531 | break; |
| 532 | |
| 533 | case 'S': |
| 534 | bStrictModecxx . . $ bStrictMode. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 535 | break; |
| 536 | |
| 537 | case 'R': |
| 538 | bRemoveOutBincxx . . $ bRemoveOutBin. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 539 | break; |
| 540 | |
| 541 | case 'm': /* F_passes */ |
| 542 | argVal = atolcxx . . $ atol(3c95bd14d5d5d286).(str); |
| 543 | if (argVal <= 64) { |
| 544 | paniccxx . . $ panic(85c52e162fed56f9).("-m Switch invalid argument, should be > 64"); |
| 545 | } else { |
| 546 | maxFileSizecxx . . $ maxFileSize. = argVal; |
| 547 | } |
| 548 | break; |
| 549 | |
| 550 | default: |
| 551 | goto fail; |
| 552 | } |
| 553 | continue; |
| 554 | } |
| 555 | goto fail; |
| 556 | } |
| 557 | |
| 558 | bStopAtEndcxx . . $ bStopAtEnd. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).((nMaxPassescxx . . $ nMaxPasses.+1) * sizeof(boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!)); |
| 559 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(bStopAtEndcxx . . $ bStopAtEnd., 0, nMaxPassescxx . . $ nMaxPasses.+1); // we dont count from zero ! (for fewer code changes) |
| 560 | |
| 561 | /* INITIAL SEGMENT */ |
| 562 | |
| 563 | { |
| 564 | SEGMENTcxx . . $ `src/asm.h:159:9`! *seg = (SEGMENTcxx . . $ `src/asm.h:159:9`! *)permalloccxx . . $ permalloc(ff224f080444ee45).(sizeof(SEGMENTcxx . . $ `src/asm.h:159:9`!)); |
| 565 | seg->namecxx . . $ _SEGMENT#name. = strcpycxx . . $ strcpy(b7b3a83273496486).(permalloccxx . . $ permalloc(ff224f080444ee45).(sizeof(ISEGNAMEcxx . . $ `src/main.c:38:9`!)), ISEGNAMEcxx . . $ `src/main.c:38:9`!); |
| 566 | seg->flagscxx . . $ _SEGMENT#flags.= seg->rflagscxx . . $ _SEGMENT#rflags. = seg->initflagscxx . . $ _SEGMENT#initflags. = seg->initrflagscxx . . $ _SEGMENT#initrflags. = SF_UNKNOWNcxx . . $ `src/asm.h:308:9`!; |
| 567 | Csegmentcxx . . $ Csegment. = Seglistcxx . . $ Seglist. = seg; |
| 568 | } |
| 569 | /* TOP LEVEL IF */ |
| 570 | { |
| 571 | IFSTACKcxx . . $ `src/asm.h:158:9`! *ifs = (IFSTACKcxx . . $ `src/asm.h:158:9`! *)zmalloccxx . . $ zmalloc(ff224f080444ee45).(sizeof(IFSTACKcxx . . $ `src/asm.h:158:9`!)); |
| 572 | ifs->filecxx . . $ _IFSTACK#file. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 573 | ifs->flagscxx . . $ _IFSTACK#flags. = IFF_BASEcxx . . $ `src/asm.h:298:9`!; |
| 574 | ifs->acctruecxx . . $ _IFSTACK#acctrue. = 1; |
| 575 | ifs->xtruecxx . . $ _IFSTACK#xtrue. = 1; |
| 576 | Ifstackcxx . . $ Ifstack. = ifs; |
| 577 | } |
| 578 | |
| 579 | // ready error and message buffer... |
| 580 | passbuffer_clearcxx . . $ passbuffer_clear(d4f767463ce0a6b3).(ERRORBUFcxx . . $ `src/main.c:61:9`!); |
| 581 | passbuffer_clearcxx . . $ passbuffer_clear(d4f767463ce0a6b3).(MSGBUFcxx . . $ `src/main.c:62:9`!); |
| 582 | |
| 583 | |
| 584 | nextpass: |
| 585 | |
| 586 | |
| 587 | if ( F_verbosecxx . . $ F_verbose. ) |
| 588 | { |
| 589 | putscxx . . $ puts(5c4306d8553b3696).(""); |
| 590 | printfcxx . . $ printf(581fddd72a8db8fc).("START OF PASS: %d\n", passcxx . . $ pass.); |
| 591 | } |
| 592 | |
| 593 | Localindexcxx . . $ Localindex. = Lastlocalindexcxx . . $ Lastlocalindex. = 0; |
| 594 | |
| 595 | Localdollarindexcxx . . $ Localdollarindex. = Lastlocaldollarindexcxx . . $ Lastlocaldollarindex. = 0; |
| 596 | |
| 597 | /*_fmode = 0x8000;*/ |
| 598 | FI_tempcxx . . $ FI_temp. = fopencxx . . $ fopen(82ec0787cd37e0a3).(F_outfilecxx . . $ F_outfile., "wb"); |
| 599 | /*_fmode = 0;*/ |
| 600 | Fisclearcxx . . $ Fisclear. = 1; |
| 601 | CheckSumcxx . . $ CheckSum. = 0; |
| 602 | if (FI_tempcxx . . $ FI_temp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 603 | printfcxx . . $ printf(581fddd72a8db8fc).("Warning: Unable to [re]open '%s'\n", F_outfilecxx . . $ F_outfile.); |
| 604 | return ERROR_FILE_ERRORcxx . . $ ERROR_FILE_ERROR.; |
| 605 | } |
| 606 | if (F_listfilecxx . . $ F_listfile.) { |
| 607 | |
| 608 | FI_listfilecxx . . $ FI_listfile. = fopencxx . . $ fopen(82ec0787cd37e0a3).(F_listfilecxx . . $ F_listfile., |
| 609 | F_ListAllPassescxx . . $ F_ListAllPasses. && (passcxx . . $ pass. > 1)? "ab" : "wb"); |
| 610 | |
| 611 | if (FI_listfilecxx . . $ FI_listfile. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 612 | printfcxx . . $ printf(581fddd72a8db8fc).("Warning: Unable to [re]open '%s'\n", F_listfilecxx . . $ F_listfile.); |
| 613 | return ERROR_FILE_ERRORcxx . . $ ERROR_FILE_ERROR.; |
| 614 | } |
| 615 | } |
| 616 | pushincludecxx . . $ pushinclude(fda57c8427c60377).(av[1]); |
| 617 | |
| 618 | while ( pIncfilecxx . . $ pIncfile. ) |
| 619 | { |
| 620 | for (;;) { |
| 621 | const char *comment; |
| 622 | if ( pIncfilecxx . . $ pIncfile.->flagscxx . . $ _INCFILE#flags. & INF_MACROcxx . . $ `src/asm.h:267:9`!) { |
| 623 | if ( pIncfilecxx . . $ pIncfile.->strlistcxx . . $ _INCFILE#strlist. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 624 | Avcxx . . $ Av.[0] = ""; |
| 625 | v_mexitcxx . . $ v_mexit(b7f07ba78920e729).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 626 | continue; |
| 627 | } |
| 628 | strcpycxx . . $ strcpy(b7b3a83273496486).(buf, pIncfilecxx . . $ pIncfile.->strlistcxx . . $ _INCFILE#strlist.->bufcxx . . $ _STRLIST#buf.); |
| 629 | pIncfilecxx . . $ pIncfile.->strlistcxx . . $ _INCFILE#strlist. = pIncfilecxx . . $ pIncfile.->strlistcxx . . $ _INCFILE#strlist.->nextcxx . . $ _STRLIST#next.; |
| 630 | } |
| 631 | else |
| 632 | { |
| 633 | if (fgetscxx . . $ fgets(efb0aaba7ac866ae).(buf, MAXLINEcxx . . $ `src/asm.h:67:9`!, pIncfilecxx . . $ pIncfile.->ficxx . . $ _INCFILE#fi.) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 634 | break; |
| 635 | } |
| 636 | |
| 637 | if (Xdebugcxx . . $ Xdebug.) |
| 638 | printfcxx . . $ printf(581fddd72a8db8fc).("%08lx %s\n", (unsigned long) pIncfilecxx . . $ pIncfile., buf); |
| 639 | |
| 640 | comment = cleanupcxx . . $ cleanup(d2bc64eaa2e6f7db).(buf, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 641 | ++pIncfilecxx . . $ pIncfile.->linenocxx . . $ _INCFILE#lineno.; |
| 642 | mne = parsecxx . . $ parse(4e299f1ac3401714).(buf); |
| 643 | |
| 644 | if (Avcxx . . $ Av.[1][0]) |
| 645 | { |
| 646 | if (mne) |
| 647 | { |
| 648 | if ((mne->flagscxx . . $ _MNE#flags. & MF_IFcxx . . $ `src/asm.h:239:9`!) || (Ifstackcxx . . $ Ifstack.->xtruecxx . . $ _IFSTACK#xtrue. && Ifstackcxx . . $ Ifstack.->acctruecxx . . $ _IFSTACK#acctrue.)) |
| 649 | (*mne->vectcxx . . $ _MNE#vect.)(Avcxx . . $ Av.[2], mne); |
| 650 | } |
| 651 | else |
| 652 | { |
| 653 | if (Ifstackcxx . . $ Ifstack.->xtruecxx . . $ _IFSTACK#xtrue. && Ifstackcxx . . $ Ifstack.->acctruecxx . . $ _IFSTACK#acctrue.) |
| 654 | asmerrcxx . . $ asmerr(1daa6892c969c96d).( ERROR_UNKNOWN_MNEMONICcxx . . $ ERROR_UNKNOWN_MNEMONIC., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, Avcxx . . $ Av.[1] ); |
| 655 | } |
| 656 | |
| 657 | } |
| 658 | else |
| 659 | { |
| 660 | if (Ifstackcxx . . $ Ifstack.->xtruecxx . . $ _IFSTACK#xtrue. && Ifstackcxx . . $ Ifstack.->acctruecxx . . $ _IFSTACK#acctrue.) |
| 661 | programlabelcxx . . $ programlabel(49f6e7a06ebc5aa8).(); |
| 662 | } |
| 663 | |
| 664 | if (F_listfilecxx . . $ F_listfile. && ListModecxx . . $ ListMode.) |
| 665 | outlistfilecxx . . $ outlistfile(85c52e162fed56f9).(comment); |
| 666 | } |
| 667 | |
| 668 | while (Reploopcxx . . $ Reploop. && Reploopcxx . . $ Reploop.->filecxx . . $ _REPLOOP#file. == pIncfilecxx . . $ pIncfile.) |
| 669 | rmnodecxx . . $ rmnode(c5057b5a64f892f7).((void **)&Reploopcxx . . $ Reploop., sizeof(REPLOOPcxx . . $ `src/asm.h:157:9`!)); |
| 670 | |
| 671 | while (Ifstackcxx . . $ Ifstack.->filecxx . . $ _IFSTACK#file. == pIncfilecxx . . $ pIncfile.) |
| 672 | rmnodecxx . . $ rmnode(c5057b5a64f892f7).((void **)&Ifstackcxx . . $ Ifstack., sizeof(IFSTACKcxx . . $ `src/asm.h:158:9`!)); |
| 673 | |
| 674 | fclosecxx . . $ fclose(89bc1efcdac0ca22).( pIncfilecxx . . $ pIncfile.->ficxx . . $ _INCFILE#fi. ); |
| 675 | freecxx . . $ free(5d22bdacc48458e8).( pIncfilecxx . . $ pIncfile.->namecxx . . $ _INCFILE#name. ); |
| 676 | --Inclevelcxx . . $ Inclevel.; |
| 677 | rmnodecxx . . $ rmnode(c5057b5a64f892f7).((void **)&pIncfilecxx . . $ pIncfile., sizeof(INCFILEcxx . . $ `src/asm.h:156:9`!)); |
| 678 | |
| 679 | if ( pIncfilecxx . . $ pIncfile. ) |
| 680 | { |
| 681 | if (F_verbosecxx . . $ F_verbose. > 3) |
| 682 | printfcxx . . $ printf(581fddd72a8db8fc).("back to: %s\n", pIncfilecxx . . $ pIncfile.->namecxx . . $ _INCFILE#name.); |
| 683 | |
| 684 | if (F_listfilecxx . . $ F_listfile.) |
| 685 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(FI_listfilecxx . . $ FI_listfile., "------- FILE %s\n", pIncfilecxx . . $ pIncfile.->namecxx . . $ _INCFILE#name.); |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | |
| 690 | |
| 691 | if ( F_verbosecxx . . $ F_verbose. >= 1 ) |
| 692 | ShowSegmentscxx . . $ ShowSegments(49f6e7a06ebc5aa8).(); |
| 693 | |
| 694 | if ( F_verbosecxx . . $ F_verbose. >= 3 ) |
| 695 | { |
| 696 | if ( !Redocxx . . $ Redo. || ( F_verbosecxx . . $ F_verbose. == 4 ) ) |
| 697 | ShowSymbolscxx . . $ ShowSymbols(830a66354e950082).( stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, *pbTableSort ); |
| 698 | |
| 699 | ShowUnresolvedSymbolscxx . . $ ShowUnresolvedSymbols(b126dc7c1de90089).(); |
| 700 | } |
| 701 | |
| 702 | closegeneratecxx . . $ closegenerate(49f6e7a06ebc5aa8).(); |
| 703 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(FI_tempcxx . . $ FI_temp.); |
| 704 | if (FI_listfilecxx . . $ FI_listfile.) |
| 705 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(FI_listfilecxx . . $ FI_listfile.); |
| 706 | |
| 707 | if (mlflagcxx . . $ mlflag.) // check if a multi-line comment is missing a terminator |
| 708 | return ERROR_MISSING_COMMENT_ENDcxx . . $ ERROR_MISSING_COMMENT_END.; |
| 709 | |
| 710 | if (Redocxx . . $ Redo.) |
| 711 | { |
| 712 | if ( !bDoAllPasses ) |
| 713 | if (Redocxx . . $ Redo. == oldredo && Redo_whycxx . . $ Redo_why. == oldwhy && Redo_evalcxx . . $ Redo_eval. == oldeval) |
| 714 | { |
| 715 | ShowUnresolvedSymbolscxx . . $ ShowUnresolvedSymbols(b126dc7c1de90089).(); |
| 716 | return ERROR_NOT_RESOLVABLEcxx . . $ ERROR_NOT_RESOLVABLE.; |
| 717 | } |
| 718 | |
| 719 | oldredo = Redocxx . . $ Redo.; |
| 720 | oldwhy = Redo_whycxx . . $ Redo_why.; |
| 721 | oldeval = Redo_evalcxx . . $ Redo_eval.; |
| 722 | Redocxx . . $ Redo. = 0; |
| 723 | Redo_whycxx . . $ Redo_why. = 0; |
| 724 | Redo_evalcxx . . $ Redo_eval. = 0; |
| 725 | |
| 726 | Redo_ifcxx . . $ Redo_if. <<= 1; |
| 727 | ++passcxx . . $ pass.; |
| 728 | |
| 729 | |
| 730 | if ( passcxx . . $ pass. > nMaxPassescxx . . $ nMaxPasses. ) |
| 731 | { |
| 732 | char sBuffer[64]; |
| 733 | sprintfcxx . . $ sprintf(26c8642d26409d6d).( sBuffer, "%d", passcxx . . $ pass. ); |
| 734 | return asmerrcxx . . $ asmerr(1daa6892c969c96d).( ERROR_TOO_MANY_PASSEScxx . . $ ERROR_TOO_MANY_PASSES., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, sBuffer ); |
| 735 | |
| 736 | } |
| 737 | else |
| 738 | { |
| 739 | passbuffer_clearcxx . . $ passbuffer_clear(d4f767463ce0a6b3).(ERRORBUFcxx . . $ `src/main.c:61:9`!); |
| 740 | passbuffer_clearcxx . . $ passbuffer_clear(d4f767463ce0a6b3).(MSGBUFcxx . . $ `src/main.c:62:9`!); |
| 741 | |
| 742 | clearrefscxx . . $ clearrefs(49f6e7a06ebc5aa8).(); |
| 743 | clearsegscxx . . $ clearsegs(49f6e7a06ebc5aa8).(); |
| 744 | goto nextpass; |
| 745 | } |
| 746 | } |
| 747 | // Do not print any errors if assembly is successful!!!!! -FXQ |
| 748 | // only print messages from last pass and if there's no errors |
| 749 | if (!bStopAtEndcxx . . $ bStopAtEnd.[passcxx . . $ pass.]) |
| 750 | { |
| 751 | passbuffer_outputcxx . . $ passbuffer_output(d4f767463ce0a6b3).(MSGBUFcxx . . $ `src/main.c:62:9`!); |
| 752 | } |
| 753 | else |
| 754 | { |
| 755 | // Only print errors if assembly is unsuccessful!!!!! |
| 756 | // by FXQ |
| 757 | passbuffer_outputcxx . . $ passbuffer_output(d4f767463ce0a6b3).(ERRORBUFcxx . . $ `src/main.c:61:9`!); |
| 758 | printfcxx . . $ printf(581fddd72a8db8fc).("Unrecoverable error(s) in pass, aborting assembly!\n"); |
| 759 | nError = ERROR_NON_ABORTcxx . . $ ERROR_NON_ABORT.; |
| 760 | } |
| 761 | |
| 762 | if (nMacroClosingscxx . . $ nMacroClosings. != nMacroDeclarationscxx . . $ nMacroDeclarations.) { |
| 763 | /* determine the file pointer to use */ |
| 764 | FILEcxx . . $ FILE# *error_file = (F_listfilecxx . . $ F_listfile. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? FI_listfilecxx . . $ FI_listfile. : stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!; |
| 765 | |
| 766 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(error_file, "premature end of file, macros opened:%d closed:%d", nMacroDeclarationscxx . . $ nMacroDeclarations., nMacroClosingscxx . . $ nMacroClosings.); |
| 767 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(error_file, "Aborting assembly\n"); |
| 768 | |
| 769 | exitcxx . . $ exit(3ca292c338df9bb3).(ERROR_MISSING_ENDMcxx . . $ ERROR_MISSING_ENDM.); |
| 770 | } |
| 771 | printfcxx . . $ printf(581fddd72a8db8fc).( "Complete. (%d)\n", nError); |
| 772 | return nError; |
| 773 | } |
| 774 | |
| 775 | void addmsgcxx . . $ addmsg(fda57c8427c60377).(char *message) // add to message buffer (FXQ) |
| 776 | { |
| 777 | passbuffer_updatecxx . . $ passbuffer_update(577809987ad7a468).(MSGBUFcxx . . $ `src/main.c:62:9`!,message); |
| 778 | } |
| 779 | |
| 780 | |
| 781 | static int tabitcxx . . $ tabit(e99f026884c896d5).(char *buf1, char *buf2) |
| 782 | { |
| 783 | char *bp, *ptr; |
| 784 | int j, k; |
| 785 | |
| 786 | bp = buf2; |
| 787 | ptr= buf1; |
| 788 | for (j = 0; *ptr && *ptr != '\n'; ++ptr, ++bp, j = (j+1)&7) { |
| 789 | *bp = *ptr; |
| 790 | if (*ptr == '\t') { |
| 791 | /* optimize out spaces before the tab */ |
| 792 | while (j > 0 && bp[-1] == ' ') { |
| 793 | bp--; |
| 794 | j--; |
| 795 | } |
| 796 | j = 0; |
| 797 | *bp = '\t'; /* recopy the tab */ |
| 798 | } |
| 799 | if (j == 7 && *bp == ' ' && bp[-1] == ' ') { |
| 800 | k = j; |
| 801 | while (k-- >= 0 && *bp == ' ') |
| 802 | --bp; |
| 803 | *++bp = '\t'; |
| 804 | } |
| 805 | } |
| 806 | while (bp != buf2 && (bp[-1] == ' ' || bp[-1] == '\t')) |
| 807 | --bp; |
| 808 | *bp++ = '\n'; |
| 809 | *bp = '\0'; |
| 810 | return (int)(bp - buf2); |
| 811 | } |
| 812 | |
| 813 | static void outlistfilecxx . . $ outlistfile(85c52e162fed56f9).(const char *comment) |
| 814 | { |
| 815 | char xtrue; |
| 816 | char c; |
| 817 | static char buf1[MAXLINEcxx . . $ `src/asm.h:67:9`!+32]; |
| 818 | static char buf2[MAXLINEcxx . . $ `src/asm.h:67:9`!+32]; |
| 819 | const char *ptr; |
| 820 | const char *dot; |
| 821 | int i, j; |
| 822 | |
| 823 | |
| 824 | if ( pIncfilecxx . . $ pIncfile.->flagscxx . . $ _INCFILE#flags. & INF_NOLISTcxx . . $ `src/asm.h:268:9`! ) |
| 825 | return; |
| 826 | |
| 827 | xtrue = (Ifstackcxx . . $ Ifstack.->xtruecxx . . $ _IFSTACK#xtrue. && Ifstackcxx . . $ Ifstack.->acctruecxx . . $ _IFSTACK#acctrue.) ? ' ' : '-'; |
| 828 | c = (Pflagscxx . . $ Pflags. & SF_BSScxx . . $ `src/asm.h:310:9`!) ? 'U' : ' '; |
| 829 | ptr = Extstrcxx . . $ Extstr.; |
| 830 | dot = ""; |
| 831 | if (ptr) |
| 832 | dot = "."; |
| 833 | else |
| 834 | ptr = ""; |
| 835 | |
| 836 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf1, "%7ld %c%s", pIncfilecxx . . $ pIncfile.->linenocxx . . $ _INCFILE#lineno., c, sftoscxx . . $ sftos(ef4cfbd1f56d9042).(Plabcxx . . $ Plab., Pflagscxx . . $ Pflags. & 7)); |
| 837 | j = strlencxx . . $ strlen(751346f8406fd082).(buf1); |
| 838 | for (i = 0; i < Glencxx . . $ Glen. && i < 4; ++i, j += 3) |
| 839 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf1+j, "%02x ", Gencxx . . $ Gen.[i]); |
| 840 | if (i < Glencxx . . $ Glen. && i == 4) |
| 841 | xtrue = '*'; |
| 842 | for (; i < 4; ++i) { |
| 843 | buf1[j] = buf1[j+1] = buf1[j+2] = ' '; |
| 844 | j += 3; |
| 845 | } |
| 846 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf1+j-1, "%c%-10s %s%s%s\t%s\n", |
| 847 | xtrue, Avcxx . . $ Av.[0], Avcxx . . $ Av.[1], dot, ptr, Avcxx . . $ Av.[2]); |
| 848 | if (comment[0]) { /* tab and comment */ |
| 849 | j = strlencxx . . $ strlen(751346f8406fd082).(buf1) - 1; |
| 850 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf1+j, "\t;%s", comment); |
| 851 | } |
| 852 | fwritecxx . . $ fwrite(ab0609fa07c47d6e).(buf2, tabitcxx . . $ tabit(e99f026884c896d5).(buf1,buf2), 1, FI_listfilecxx . . $ FI_listfile.); |
| 853 | Glencxx . . $ Glen. = 0; |
| 854 | Extstrcxx . . $ Extstr. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 855 | } |
| 856 | |
| 857 | char *sftoscxx . . $ sftos(ef4cfbd1f56d9042).(long val, int flags) |
| 858 | { |
| 859 | static char buf[ MAX_SYM_LENcxx . . $ `src/asm.h:68:9`! + 14 ]; |
| 860 | static char c; |
| 861 | char *ptr = (c) ? buf : buf + sizeof(buf) / 2; |
| 862 | |
| 863 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( buf, 0, sizeof( buf ) ); |
| 864 | |
| 865 | c = 1 - c; |
| 866 | |
| 867 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(ptr, "%04lx ", val); |
| 868 | |
| 869 | if (flags & SYM_UNKNOWNcxx . . $ `src/asm.h:326:9`!) |
| 870 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, "???? "); |
| 871 | else |
| 872 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, " " ); |
| 873 | |
| 874 | if (flags & SYM_STRINGcxx . . $ `src/asm.h:328:9`!) |
| 875 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, "str "); |
| 876 | else |
| 877 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, " " ); |
| 878 | |
| 879 | if (flags & SYM_MACROcxx . . $ `src/asm.h:330:9`!) |
| 880 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, "eqm "); |
| 881 | else |
| 882 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, " " ); |
| 883 | |
| 884 | |
| 885 | if (flags & (SYM_MASREFcxx . . $ `src/asm.h:331:9`!|SYM_SETcxx . . $ `src/asm.h:329:9`!)) |
| 886 | { |
| 887 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, "(" ); |
| 888 | } |
| 889 | else |
| 890 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, " " ); |
| 891 | |
| 892 | if (flags & (SYM_MASREFcxx . . $ `src/asm.h:331:9`!)) |
| 893 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, "R" ); |
| 894 | else |
| 895 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, " " ); |
| 896 | |
| 897 | |
| 898 | if (flags & (SYM_SETcxx . . $ `src/asm.h:329:9`!)) |
| 899 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, "S" ); |
| 900 | else |
| 901 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, " " ); |
| 902 | |
| 903 | if (flags & (SYM_MASREFcxx . . $ `src/asm.h:331:9`!|SYM_SETcxx . . $ `src/asm.h:329:9`!)) |
| 904 | { |
| 905 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, ")" ); |
| 906 | } |
| 907 | else |
| 908 | strcatcxx . . $ strcat(b7b3a83273496486).( ptr, " " ); |
| 909 | |
| 910 | |
| 911 | return ptr; |
| 912 | } |
| 913 | |
| 914 | void clearsegscxx . . $ clearsegs(49f6e7a06ebc5aa8).(void) |
| 915 | { |
| 916 | SEGMENTcxx . . $ `src/asm.h:159:9`! *seg; |
| 917 | |
| 918 | for (seg = Seglistcxx . . $ Seglist.; seg; seg = seg->nextcxx . . $ _SEGMENT#next.) { |
| 919 | seg->flagscxx . . $ _SEGMENT#flags. = (seg->flagscxx . . $ _SEGMENT#flags. & SF_BSScxx . . $ `src/asm.h:310:9`!) | SF_UNKNOWNcxx . . $ `src/asm.h:308:9`!; |
| 920 | seg->rflagscxx . . $ _SEGMENT#rflags.= seg->initflagscxx . . $ _SEGMENT#initflags. = seg->initrflagscxx . . $ _SEGMENT#initrflags. = SF_UNKNOWNcxx . . $ `src/asm.h:308:9`!; |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | |
| 925 | void clearrefscxx . . $ clearrefs(49f6e7a06ebc5aa8).(void) |
| 926 | { |
| 927 | SYMBOLcxx . . $ `src/asm.h:160:9`! *sym; |
| 928 | short i; |
| 929 | |
| 930 | for (i = 0; i < SHASHSIZEcxx . . $ `src/asm.h:165:9`!; ++i) |
| 931 | for (sym = SHashcxx . . $ SHash.[i]; sym; sym = sym->nextcxx . . $ _SYMBOL#next.) |
| 932 | sym->flagscxx . . $ _SYMBOL#flags. &= ~SYM_REFcxx . . $ `src/asm.h:327:9`!; |
| 933 | } |
| 934 | |
| 935 | |
| 936 | |
| 937 | |
| 938 | static const char *cleanupcxx . . $ cleanup(d2bc64eaa2e6f7db).(char *buf, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bDisable) |
| 939 | { |
| 940 | char *str; |
| 941 | STRLISTcxx . . $ `src/asm.h:161:9`! *strlist; |
| 942 | int arg, add; |
| 943 | const char *comment = ""; |
| 944 | |
| 945 | char *mlstart, *mlend, *semistart; |
| 946 | mlstart=strstrcxx . . $ strstr(a713fe7b9a57cf96).(buf,"/*"); |
| 947 | mlend=strstrcxx . . $ strstr(a713fe7b9a57cf96).(buf,"*/"); |
| 948 | semistart=strstrcxx . . $ strstr(a713fe7b9a57cf96).(buf,";"); |
| 949 | |
| 950 | if (mlflagcxx . . $ mlflag.) // a previous multi-line comment is in progress... |
| 951 | { |
| 952 | if ( mlend ) |
| 953 | { |
| 954 | mlflagcxx . . $ mlflag.=0; // turn off multiline comments |
| 955 | char tempbuf[MAXLINEcxx . . $ `src/asm.h:67:9`!]; |
| 956 | char *tmpc; |
| 957 | *mlend = 0; |
| 958 | tmpc = mlend+1; |
| 959 | while(*tmpc!=0) // we need to purge any newlines before we reorder the parts of the line |
| 960 | { |
| 961 | if((*tmpc == '\r')||(*tmpc == '\n')) |
| 962 | *tmpc=0; |
| 963 | tmpc++; |
| 964 | } |
| 965 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(tempbuf,MAXLINEcxx . . $ `src/asm.h:67:9`!,"%s;*/%s",mlend+2,buf); // put the comment at the end of the line |
| 966 | strncpycxx . . $ strncpy(255158a415b673b0).(buf,tempbuf,MAXLINEcxx . . $ `src/asm.h:67:9`!); |
| 967 | return(cleanupcxx . . $ cleanup(d2bc64eaa2e6f7db).(buf,bDisable)); // repeat for any single-line comments that may follow |
| 968 | } |
| 969 | else |
| 970 | { |
| 971 | memmovecxx . . $ memmove(cc817cb175f282d).(buf+1,buf,strlencxx . . $ strlen(751346f8406fd082).(buf)+1); // make room for the last comment |
| 972 | buf[0]=';'; |
| 973 | } |
| 974 | } |
| 975 | else // we're not presently in the middle of a multi-line comment... |
| 976 | { |
| 977 | // check for spurious comment close |
| 978 | if (mlend && ( (!semistart) || (mlend < semistart) ) && ( (!mlstart) || (mlend < mlstart) ) ) |
| 979 | asmerrcxx . . $ asmerr(1daa6892c969c96d).( ERROR_SPURIOUS_COMMENT_CLOSEcxx . . $ ERROR_SPURIOUS_COMMENT_CLOSE., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 980 | if (mlstart && ((!semistart) || (mlstart < semistart))) |
| 981 | { |
| 982 | if (mlend && (mlstart < mlend) && ((!semistart)||(mlend < semistart))) // single line /* */ |
| 983 | { |
| 984 | char tempbuf[MAXLINEcxx . . $ `src/asm.h:67:9`!]; |
| 985 | char *tmpc; |
| 986 | *mlstart = 0; |
| 987 | *(mlend+1)=0; |
| 988 | tmpc = mlend+2; |
| 989 | while(*tmpc!=0) // we need to purge any newlines before we reorder the parts of the line |
| 990 | { |
| 991 | if((*tmpc == '\r')||(*tmpc == '\n')) |
| 992 | *tmpc=0; |
| 993 | tmpc++; |
| 994 | } |
| 995 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(tempbuf,MAXLINEcxx . . $ `src/asm.h:67:9`!,"%s%s;/%s",buf,mlend+2,mlstart+1); // move the first comment to the end of the line |
| 996 | strcpycxx . . $ strcpy(b7b3a83273496486).(buf,tempbuf); |
| 997 | return(cleanupcxx . . $ cleanup(d2bc64eaa2e6f7db).(buf,bDisable)); // repeat for any single-line comments that may follow |
| 998 | } |
| 999 | mlflagcxx . . $ mlflag.=1; // turn on multiline comments |
| 1000 | memmovecxx . . $ memmove(cc817cb175f282d).(mlstart+1,mlstart,strlencxx . . $ strlen(751346f8406fd082).(mlstart)+1); // make room for a comment |
| 1001 | *mlstart=';'; |
| 1002 | } |
| 1003 | } |
| 1004 | |
| 1005 | for (str = buf; *str; ++str) |
| 1006 | { |
| 1007 | switch(*str) |
| 1008 | { |
| 1009 | case ';': |
| 1010 | comment = (char *)str + 1; |
| 1011 | /* FALL THROUGH */ |
| 1012 | case '\r': |
| 1013 | case '\n': |
| 1014 | goto br2; |
| 1015 | case TABcxx . . $ `src/asm.h:171:9`!: |
| 1016 | *str = ' '; |
| 1017 | break; |
| 1018 | case '\'': |
| 1019 | ++str; |
| 1020 | if (*str == TABcxx . . $ `src/asm.h:171:9`!) |
| 1021 | *str = ' '; |
| 1022 | if (*str == '\n' || *str == 0) |
| 1023 | { |
| 1024 | str[0] = ' '; |
| 1025 | str[1] = 0; |
| 1026 | } |
| 1027 | if (str[0] == ' ') |
| 1028 | str[0] = '\x80'; |
| 1029 | break; |
| 1030 | case '\"': |
| 1031 | ++str; |
| 1032 | while (*str && *str != '\"') |
| 1033 | { |
| 1034 | if (*str == ' ') |
| 1035 | *str = '\x80'; |
| 1036 | ++str; |
| 1037 | } |
| 1038 | if (*str != '\"') |
| 1039 | { |
| 1040 | asmerrcxx . . $ asmerr(1daa6892c969c96d).( ERROR_SYNTAX_ERRORcxx . . $ ERROR_SYNTAX_ERROR., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, buf ); |
| 1041 | --str; |
| 1042 | } |
| 1043 | break; |
| 1044 | case '{': |
| 1045 | if ( bDisable ) |
| 1046 | break; |
| 1047 | |
| 1048 | if (Xdebugcxx . . $ Xdebug.) |
| 1049 | printfcxx . . $ printf(581fddd72a8db8fc).("macro tail: '%s'\n", str); |
| 1050 | |
| 1051 | arg = atoicxx . . $ `src/main.c:46:9`!(str+1); |
| 1052 | for (add = 0; *str && *str != '}'; ++str) |
| 1053 | --add; |
| 1054 | if (*str != '}') |
| 1055 | { |
| 1056 | putscxx . . $ puts(5c4306d8553b3696).("end brace required"); |
| 1057 | --str; |
| 1058 | break; |
| 1059 | } |
| 1060 | --add; |
| 1061 | ++str; |
| 1062 | |
| 1063 | |
| 1064 | if (Xdebugcxx . . $ Xdebug.) |
| 1065 | printfcxx . . $ printf(581fddd72a8db8fc).("add/str: %d '%s'\n", add, str); |
| 1066 | |
| 1067 | for (strlist = pIncfilecxx . . $ pIncfile.->argscxx . . $ _INCFILE#args.; arg && strlist;) |
| 1068 | { |
| 1069 | --arg; |
| 1070 | strlist = strlist->nextcxx . . $ _STRLIST#next.; |
| 1071 | } |
| 1072 | |
| 1073 | if (strlist) |
| 1074 | { |
| 1075 | add += strlencxx . . $ strlen(751346f8406fd082).(strlist->bufcxx . . $ _STRLIST#buf.); |
| 1076 | |
| 1077 | if (Xdebugcxx . . $ Xdebug.) |
| 1078 | printfcxx . . $ printf(581fddd72a8db8fc).("strlist: '%s' %zu\n", strlist->bufcxx . . $ _STRLIST#buf., strlencxx . . $ strlen(751346f8406fd082).(strlist->bufcxx . . $ _STRLIST#buf.)); |
| 1079 | |
| 1080 | if (str + add + strlencxx . . $ strlen(751346f8406fd082).(str) + 1 > buf + MAXLINEcxx . . $ `src/asm.h:67:9`!) |
| 1081 | { |
| 1082 | if (Xdebugcxx . . $ Xdebug.) |
| 1083 | printfcxx . . $ printf(581fddd72a8db8fc).("str %8ld buf %8ld (add/strlen(str)): %d %ld\n", |
| 1084 | (unsigned long)str, (unsigned long)buf, add, (long)strlencxx . . $ strlen(751346f8406fd082).(str)); |
| 1085 | paniccxx . . $ panic(85c52e162fed56f9).("failure1"); |
| 1086 | } |
| 1087 | |
| 1088 | memmovecxx . . $ memmove(cc817cb175f282d).(str + add, str, strlencxx . . $ strlen(751346f8406fd082).(str)+1); |
| 1089 | str += add; |
| 1090 | if (str - strlencxx . . $ strlen(751346f8406fd082).(strlist->bufcxx . . $ _STRLIST#buf.) < buf) |
| 1091 | paniccxx . . $ panic(85c52e162fed56f9).("failure2"); |
| 1092 | memmovecxx . . $ memmove(cc817cb175f282d).(str - strlencxx . . $ strlen(751346f8406fd082).(strlist->bufcxx . . $ _STRLIST#buf.), strlist->bufcxx . . $ _STRLIST#buf., strlencxx . . $ strlen(751346f8406fd082).(strlist->bufcxx . . $ _STRLIST#buf.)); |
| 1093 | str -= strlencxx . . $ strlen(751346f8406fd082).(strlist->bufcxx . . $ _STRLIST#buf.); |
| 1094 | if (str < buf || str >= buf + MAXLINEcxx . . $ `src/asm.h:67:9`!) |
| 1095 | paniccxx . . $ panic(85c52e162fed56f9).("failure 3"); |
| 1096 | --str; /* for loop increments string */ |
| 1097 | } |
| 1098 | else |
| 1099 | { |
| 1100 | asmerrcxx . . $ asmerr(1daa6892c969c96d).( ERROR_NOT_ENOUGH_ARGUMENTS_PASSED_TO_MACROcxx . . $ ERROR_NOT_ENOUGH_ARGUMENTS_PASSED_TO_MACRO., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 1101 | goto br2; |
| 1102 | } |
| 1103 | break; |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | br2: |
| 1108 | while(str != buf && *(str-1) == ' ') |
| 1109 | --str; |
| 1110 | *str = 0; |
| 1111 | |
| 1112 | return comment; |
| 1113 | } |
| 1114 | |
| 1115 | void paniccxx . . $ panic(85c52e162fed56f9).(const char *str) |
| 1116 | { |
| 1117 | putscxx . . $ puts(5c4306d8553b3696).(str); |
| 1118 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 1119 | } |
| 1120 | |
| 1121 | /* |
| 1122 | * .dir direct x |
| 1123 | * .ext extended x |
| 1124 | * .r relative x |
| 1125 | * .x index, no offset x |
| 1126 | * .x8 index, byte offset x |
| 1127 | * .x16 index, word offset x |
| 1128 | * .bit bit set/clr |
| 1129 | * .bbr bit and branch |
| 1130 | * .imp implied (inherent) x |
| 1131 | * .b x |
| 1132 | * .w x |
| 1133 | * .l x |
| 1134 | * .u x |
| 1135 | * .s swapped short, force other endian with DC |
| 1136 | */ |
| 1137 | |
| 1138 | |
| 1139 | void findextcxx . . $ findext(fda57c8427c60377).(char *str) |
| 1140 | { |
| 1141 | Mnextcxx . . $ Mnext. = -1; |
| 1142 | Extstrcxx . . $ Extstr. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1143 | |
| 1144 | if (str[0] == '.') { /* Allow .OP for OP */ |
| 1145 | return; |
| 1146 | } |
| 1147 | |
| 1148 | while (*str && *str != '.') |
| 1149 | ++str; |
| 1150 | if (*str) { |
| 1151 | *str = 0; |
| 1152 | ++str; |
| 1153 | Extstrcxx . . $ Extstr. = str; |
| 1154 | switch(str[0]|0x20) { |
| 1155 | case 's': |
| 1156 | Mnextcxx . . $ Mnext. = AM_OTHER_ENDIANcxx . . $ AM_OTHER_ENDIAN.; |
| 1157 | return; |
| 1158 | |
| 1159 | case '0': |
| 1160 | case 'i': |
| 1161 | Mnextcxx . . $ Mnext. = AM_IMPcxx . . $ AM_IMP.; |
| 1162 | switch(str[1]|0x20) { |
| 1163 | case 'x': |
| 1164 | Mnextcxx . . $ Mnext. = AM_0Xcxx . . $ AM_0X.; |
| 1165 | break; |
| 1166 | case 'y': |
| 1167 | Mnextcxx . . $ Mnext. = AM_0Ycxx . . $ AM_0Y.; |
| 1168 | break; |
| 1169 | case 'n': |
| 1170 | Mnextcxx . . $ Mnext. = AM_INDWORDcxx . . $ AM_INDWORD.; |
| 1171 | break; |
| 1172 | } |
| 1173 | return; |
| 1174 | case 'd': |
| 1175 | case 'b': |
| 1176 | case 'z': |
| 1177 | switch(str[1]|0x20) { |
| 1178 | case 'x': |
| 1179 | Mnextcxx . . $ Mnext. = AM_BYTEADRXcxx . . $ AM_BYTEADRX.; |
| 1180 | break; |
| 1181 | case 'y': |
| 1182 | Mnextcxx . . $ Mnext. = AM_BYTEADRYcxx . . $ AM_BYTEADRY.; |
| 1183 | break; |
| 1184 | case 'i': |
| 1185 | Mnextcxx . . $ Mnext. = AM_BITMODcxx . . $ AM_BITMOD.; |
| 1186 | break; |
| 1187 | case 'b': |
| 1188 | Mnextcxx . . $ Mnext. = AM_BITBRAMODcxx . . $ AM_BITBRAMOD.; |
| 1189 | break; |
| 1190 | default: |
| 1191 | Mnextcxx . . $ Mnext. = AM_BYTEADRcxx . . $ AM_BYTEADR.; |
| 1192 | break; |
| 1193 | } |
| 1194 | return; |
| 1195 | case 'e': |
| 1196 | case 'w': |
| 1197 | case 'a': |
| 1198 | switch(str[1]|0x20) { |
| 1199 | case 'x': |
| 1200 | Mnextcxx . . $ Mnext. = AM_WORDADRXcxx . . $ AM_WORDADRX.; |
| 1201 | break; |
| 1202 | case 'y': |
| 1203 | Mnextcxx . . $ Mnext. = AM_WORDADRYcxx . . $ AM_WORDADRY.; |
| 1204 | break; |
| 1205 | default: |
| 1206 | Mnextcxx . . $ Mnext. = AM_WORDADRcxx . . $ AM_WORDADR.; |
| 1207 | break; |
| 1208 | } |
| 1209 | return; |
| 1210 | case 'l': |
| 1211 | Mnextcxx . . $ Mnext. = AM_LONGcxx . . $ AM_LONG.; |
| 1212 | return; |
| 1213 | case 'r': |
| 1214 | Mnextcxx . . $ Mnext. = AM_RELcxx . . $ AM_REL.; |
| 1215 | return; |
| 1216 | case 'u': |
| 1217 | Mnextcxx . . $ Mnext. = AM_BSScxx . . $ AM_BSS.; |
| 1218 | return; |
| 1219 | } |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | /* |
| 1224 | * bytes arg will eventually be used to implement a linked list of free |
| 1225 | * nodes. |
| 1226 | * Assumes *base is really a pointer to a structure with .next as the first |
| 1227 | * member. |
| 1228 | */ |
| 1229 | |
| 1230 | void rmnodecxx . . $ rmnode(c5057b5a64f892f7).(void **base, int bytes) |
| 1231 | { |
| 1232 | void *node; |
| 1233 | |
| 1234 | if ((node = *base) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1235 | *base = *(void **)node; |
| 1236 | freecxx . . $ free(5d22bdacc48458e8).(node); |
| 1237 | } |
| 1238 | } |
| 1239 | |
| 1240 | /* |
| 1241 | * Parse into three arguments: Av[0], Av[1], Av[2] |
| 1242 | */ |
| 1243 | MNEMONICcxx . . $ `src/asm.h:154:9`! *parsecxx . . $ parse(4e299f1ac3401714).(char *buf) |
| 1244 | { |
| 1245 | int i, j; |
| 1246 | MNEMONICcxx . . $ `src/asm.h:154:9`! *mne = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1247 | int labelundefined = 0; |
| 1248 | |
| 1249 | i = 0; |
| 1250 | j = 1; |
| 1251 | |
| 1252 | /* |
| 1253 | If the first non-space is a ^, skip all further spaces too. |
| 1254 | This means what follows is a label. |
| 1255 | If the first non-space is a #, what follows is a directive/opcode. |
| 1256 | */ |
| 1257 | while (buf[i] == ' ') |
| 1258 | ++i; |
| 1259 | if (buf[i] == '^') { |
| 1260 | ++i; |
| 1261 | while (buf[i] == ' ') |
| 1262 | ++i; |
| 1263 | } else if (buf[i] == '#') { |
| 1264 | buf[i] = ' '; /* label separator */ |
| 1265 | } else |
| 1266 | i = 0; |
| 1267 | |
| 1268 | Avcxx . . $ Av.[0] = Avbufcxx . . $ Avbuf. + j; |
| 1269 | while (buf[i] && buf[i] != ' ' && buf[i] != '=') { |
| 1270 | |
| 1271 | if (buf[i] == ':') { |
| 1272 | i++; |
| 1273 | break; |
| 1274 | } |
| 1275 | |
| 1276 | if (buf[i] == ',') // we have label arguments |
| 1277 | { |
| 1278 | if(buf[i+1]=='"') // is it a string constant? |
| 1279 | { |
| 1280 | i=i+2; // advance to string contents |
| 1281 | while (buf[i] && buf[i] != '"' && buf[i] != ' ' && buf[i] != ',' && buf[i] != ':') |
| 1282 | { |
| 1283 | Avbufcxx . . $ Avbuf.[j++] = buf[i++]; |
| 1284 | } |
| 1285 | if (buf[i] && buf[i]=='"') |
| 1286 | { |
| 1287 | i++; |
| 1288 | continue; |
| 1289 | } |
| 1290 | else |
| 1291 | { |
| 1292 | labelundefined++; |
| 1293 | asmerrcxx . . $ asmerr(1daa6892c969c96d).( ERROR_SYNTAX_ERRORcxx . . $ ERROR_SYNTAX_ERROR., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, buf ); |
| 1294 | continue; |
| 1295 | } |
| 1296 | } |
| 1297 | else // or else it's a symbol to be evaluated, and added to the label |
| 1298 | { |
| 1299 | int t; |
| 1300 | char tempbuf[257]; |
| 1301 | char tempval[257]; |
| 1302 | SYMBOLcxx . . $ `src/asm.h:160:9`! *symarg; |
| 1303 | strncpycxx . . $ strncpy(255158a415b673b0).(tempbuf,buf+i+1,256); |
| 1304 | tempbuf[256]=0; |
| 1305 | for(t=0;t<strlencxx . . $ strlen(751346f8406fd082).(tempbuf);t++) |
| 1306 | { |
| 1307 | if(tempbuf[t] == ',') |
| 1308 | tempbuf[t]=0; |
| 1309 | } |
| 1310 | symarg = evalcxx . . $ eval(83a8820e5b78665b).(tempbuf,0); |
| 1311 | if(symarg) |
| 1312 | { |
| 1313 | if (symarg->flagscxx . . $ _SYMBOL#flags. & SYM_UNKNOWNcxx . . $ `src/asm.h:326:9`!) // one of the arguments isn't defined yet |
| 1314 | labelundefined++; // ensure the label we're creating doesn't get used |
| 1315 | else |
| 1316 | { |
| 1317 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(tempval,256,"%d",(unsigned)symarg->valuecxx . . $ _SYMBOL#value.); |
| 1318 | strcpycxx . . $ strcpy(b7b3a83273496486).(Avbufcxx . . $ Avbuf.+j,tempval); |
| 1319 | j=j+strlencxx . . $ strlen(751346f8406fd082).(tempval); |
| 1320 | } |
| 1321 | } |
| 1322 | i++; |
| 1323 | while (buf[i] && buf[i] != ' ' && buf[i] != '=' && buf[i] != ','&& buf[i] != ':') |
| 1324 | i++; |
| 1325 | } |
| 1326 | continue; |
| 1327 | } |
| 1328 | |
| 1329 | if ((unsigned char)buf[i] == 0x80) |
| 1330 | buf[i] = ' '; |
| 1331 | Avbufcxx . . $ Avbuf.[j++] = buf[i++]; |
| 1332 | } |
| 1333 | Avbufcxx . . $ Avbuf.[j++] = 0; |
| 1334 | |
| 1335 | // if the label has arguments that aren't defined, we need to scuttle it |
| 1336 | // to avoid a partial label being used. |
| 1337 | if(labelundefined) |
| 1338 | { |
| 1339 | j=1; |
| 1340 | Avbufcxx . . $ Avbuf.[j++] = 0; |
| 1341 | } |
| 1342 | |
| 1343 | /* Parse the second word of the line */ |
| 1344 | while (buf[i] == ' ') |
| 1345 | ++i; |
| 1346 | Avcxx . . $ Av.[1] = Avbufcxx . . $ Avbuf. + j; |
| 1347 | if (buf[i] == '=') { |
| 1348 | /* '=' directly seperates Av[0] and Av[2] */ |
| 1349 | Avbufcxx . . $ Avbuf.[j++] = buf[i++]; |
| 1350 | } else while (buf[i] && buf[i] != ' ') { |
| 1351 | if ((unsigned char)buf[i] == 0x80) |
| 1352 | buf[i] = ' '; |
| 1353 | Avbufcxx . . $ Avbuf.[j++] = buf[i++]; |
| 1354 | } |
| 1355 | Avbufcxx . . $ Avbuf.[j++] = 0; |
| 1356 | /* and analyse it as an opcode */ |
| 1357 | findextcxx . . $ findext(fda57c8427c60377).(Avcxx . . $ Av.[1]); |
| 1358 | mne = findmnecxx . . $ findmne(4e299f1ac3401714).(Avcxx . . $ Av.[1]); |
| 1359 | |
| 1360 | /* Parse the rest of the line */ |
| 1361 | while (buf[i] == ' ') |
| 1362 | ++i; |
| 1363 | Avcxx . . $ Av.[2] = Avbufcxx . . $ Avbuf. + j; |
| 1364 | while (buf[i]) { |
| 1365 | if (buf[i] == ' ') { |
| 1366 | while(buf[i+1] == ' ') |
| 1367 | ++i; |
| 1368 | } |
| 1369 | if ((unsigned char)buf[i] == 0x80) |
| 1370 | buf[i] = ' '; |
| 1371 | Avbufcxx . . $ Avbuf.[j++] = buf[i++]; |
| 1372 | } |
| 1373 | Avbufcxx . . $ Avbuf.[j] = 0; |
| 1374 | |
| 1375 | if (mne != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1376 | if (mne->flagscxx . . $ _MNE#flags. & MF_BEGMcxx . . $ `src/asm.h:238:9`!) { |
| 1377 | nMacroDeclarationscxx . . $ nMacroDeclarations.++; |
| 1378 | } |
| 1379 | if (mne->flagscxx . . $ _MNE#flags. & MF_ENDMcxx . . $ `src/asm.h:244:9`!) { |
| 1380 | nMacroClosingscxx . . $ nMacroClosings.++; |
| 1381 | } |
| 1382 | } |
| 1383 | return mne; |
| 1384 | } |
| 1385 | |
| 1386 | |
| 1387 | |
| 1388 | MNEMONICcxx . . $ `src/asm.h:154:9`! *findmnecxx . . $ findmne(4e299f1ac3401714).(char *str) |
| 1389 | { |
| 1390 | int h,k; |
| 1391 | int i; |
| 1392 | char c; |
| 1393 | MNEMONICcxx . . $ `src/asm.h:154:9`! *mne; |
| 1394 | char buf[64]; |
| 1395 | |
| 1396 | |
| 1397 | if (str[0] == '.') { /* Allow .OP for OP */ |
| 1398 | str++; |
| 1399 | } |
| 1400 | |
| 1401 | for (i = 0; (c = str[i]); ++i) { |
| 1402 | if (c >= 'A' && c <= 'Z') |
| 1403 | c += 'a' - 'A'; |
| 1404 | buf[i] = c; |
| 1405 | } |
| 1406 | buf[i] = 0; |
| 1407 | h = hash1cxx . . $ hash1(c61c63047ce273de).(buf); |
| 1408 | mne = MHashcxx . . $ MHash.[h]; |
| 1409 | k = 0; |
| 1410 | while (mne != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1411 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buf, mne->namecxx . . $ _MNE#name.) == 0) |
| 1412 | break; |
| 1413 | |
| 1414 | k++; |
| 1415 | mne = mne->nextcxx . . $ _MNE#next.; |
| 1416 | if (mne != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1417 | if ((mne == mne->nextcxx . . $ _MNE#next.) && (k > 5)) { // any number bigger than 1 would do |
| 1418 | // should not happen at all, I'm not paranoid, I've had this problem really |
| 1419 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"[%s] [%s] %08lx %08lx\n", buf, mne->namecxx . . $ _MNE#name., (long)mne, (long)mne->nextcxx . . $ _MNE#next.); |
| 1420 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"BUG: %s:%d: chained list looped to itself and no match, would lock up endlessly\n", __FILE__, __LINE__); |
| 1421 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; // we need to return NULL here or the program will get stuck in an endless loop |
| 1422 | // the BUG vanished with increased hashtable |
| 1423 | } |
| 1424 | } |
| 1425 | } |
| 1426 | return mne; |
| 1427 | } |
| 1428 | |
| 1429 | void v_macrocxx . . $ v_macro(b7f07ba78920e729).(char *str, MNEMONICcxx . . $ `src/asm.h:154:9`! *dummy) |
| 1430 | { |
| 1431 | STRLISTcxx . . $ `src/asm.h:161:9`! *base; |
| 1432 | int defined = 0; |
| 1433 | STRLISTcxx . . $ `src/asm.h:161:9`! **slp, *sl; |
| 1434 | MACROcxx . . $ `src/asm.h:155:9`! *mac; /* slp, mac: might be used uninitialised */ |
| 1435 | MNEMONICcxx . . $ `src/asm.h:154:9`! *mne; |
| 1436 | unsigned int i; |
| 1437 | char buf[MAXLINEcxx . . $ `src/asm.h:67:9`!]; |
| 1438 | int skipit = !(Ifstackcxx . . $ Ifstack.->xtruecxx . . $ _IFSTACK#xtrue. && Ifstackcxx . . $ Ifstack.->acctruecxx . . $ _IFSTACK#acctrue.); |
| 1439 | |
| 1440 | strlowercxx . . $ strlower(7a9722d75b371431).(str); |
| 1441 | mne = findmnecxx . . $ findmne(4e299f1ac3401714).(str); |
| 1442 | |
| 1443 | if (skipit) { |
| 1444 | defined = 1; |
| 1445 | } else { |
| 1446 | defined = (mne != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1447 | if (F_listfilecxx . . $ F_listfile. && ListModecxx . . $ ListMode.) |
| 1448 | outlistfilecxx . . $ outlistfile(85c52e162fed56f9).(""); |
| 1449 | } |
| 1450 | if (!defined) { |
| 1451 | base = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1452 | slp = &base; |
| 1453 | mac = (MACROcxx . . $ `src/asm.h:155:9`! *)permalloccxx . . $ permalloc(ff224f080444ee45).(sizeof(MACROcxx . . $ `src/asm.h:155:9`!)); |
| 1454 | i = hash1cxx . . $ hash1(c61c63047ce273de).(str); |
| 1455 | mac->nextcxx . . $ _MACRO#next. = (MACROcxx . . $ `src/asm.h:155:9`! *)MHashcxx . . $ MHash.[i]; |
| 1456 | mac->vectcxx . . $ _MACRO#vect. = v_execmaccxx . . $ v_execmac(f68f5bbf1ad34a70).; |
| 1457 | mac->namecxx . . $ _MACRO#name. = strcpycxx . . $ strcpy(b7b3a83273496486).(permalloccxx . . $ permalloc(ff224f080444ee45).(strlencxx . . $ strlen(751346f8406fd082).(str)+1), str); |
| 1458 | mac->flagscxx . . $ _MACRO#flags. = MF_MACROcxx . . $ `src/asm.h:240:9`!; |
| 1459 | mac->defpasscxx . . $ _MACRO#defpass. = passcxx . . $ pass.; |
| 1460 | if (mac == mac->nextcxx . . $ _MACRO#next.) { |
| 1461 | // should not happen |
| 1462 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"BUG: %s:%d: permalloc() returned the same value twice, expect severe problems\n", __FILE__, __LINE__); |
| 1463 | } |
| 1464 | MHashcxx . . $ MHash.[i] = (MNEMONICcxx . . $ `src/asm.h:154:9`! *)mac; |
| 1465 | } |
| 1466 | else { |
| 1467 | mac = (MACROcxx . . $ `src/asm.h:155:9`! *)mne; |
| 1468 | if( (bStrictModecxx . . $ bStrictMode.) && (mac != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (mac->defpasscxx . . $ _MACRO#defpass. == passcxx . . $ pass.) ) |
| 1469 | asmerrcxx . . $ asmerr(1daa6892c969c96d).( ERROR_MACRO_REPEATEDcxx . . $ ERROR_MACRO_REPEATED., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, str ); |
| 1470 | } |
| 1471 | while (fgetscxx . . $ fgets(efb0aaba7ac866ae).(buf, MAXLINEcxx . . $ `src/asm.h:67:9`!, pIncfilecxx . . $ pIncfile.->ficxx . . $ _INCFILE#fi.)) { |
| 1472 | const char *comment; |
| 1473 | |
| 1474 | if (Xdebugcxx . . $ Xdebug.) |
| 1475 | printfcxx . . $ printf(581fddd72a8db8fc).("%08lx %s\n", (unsigned long) pIncfilecxx . . $ pIncfile., buf); |
| 1476 | |
| 1477 | ++pIncfilecxx . . $ pIncfile.->linenocxx . . $ _INCFILE#lineno.; |
| 1478 | |
| 1479 | |
| 1480 | comment = cleanupcxx . . $ cleanup(d2bc64eaa2e6f7db).(buf, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!); |
| 1481 | |
| 1482 | mne = parsecxx . . $ parse(4e299f1ac3401714).(buf); |
| 1483 | if (Avcxx . . $ Av.[1][0]) { |
| 1484 | if (mne != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { // for some reason I got a segfault while accessing mne->flags, should not happen but gdb said it was here |
| 1485 | if (mne->flagscxx . . $ _MNE#flags. & MF_ENDMcxx . . $ `src/asm.h:244:9`!) { |
| 1486 | if (!defined) |
| 1487 | mac->strlistcxx . . $ _MACRO#strlist. = base; |
| 1488 | return; |
| 1489 | } |
| 1490 | } |
| 1491 | } |
| 1492 | if (!skipit && F_listfilecxx . . $ F_listfile. && ListModecxx . . $ ListMode.) |
| 1493 | outlistfilecxx . . $ outlistfile(85c52e162fed56f9).(comment); |
| 1494 | if (!defined) { |
| 1495 | sl = (STRLISTcxx . . $ `src/asm.h:161:9`! *)permalloccxx . . $ permalloc(ff224f080444ee45).(STRLISTSIZEcxx . . $ `src/asm.h:236:9`!+1+strlencxx . . $ strlen(751346f8406fd082).(buf)); |
| 1496 | strcpycxx . . $ strcpy(b7b3a83273496486).(sl->bufcxx . . $ _STRLIST#buf., buf); |
| 1497 | *slp = sl; |
| 1498 | slp = &sl->nextcxx . . $ _STRLIST#next.; |
| 1499 | } |
| 1500 | } |
| 1501 | asmerrcxx . . $ asmerr(1daa6892c969c96d).( ERROR_PREMATURE_EOFcxx . . $ ERROR_PREMATURE_EOF., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 1502 | } |
| 1503 | |
| 1504 | |
| 1505 | void addhashtablecxx . . $ addhashtable(c2a72e93142ff88d).(MNEMONICcxx . . $ `src/asm.h:154:9`! *mne) |
| 1506 | { |
| 1507 | int i, j; |
| 1508 | unsigned int opcode[NUMOCcxx . . $ NUMOC.]; |
| 1509 | |
| 1510 | for (; mne->vectcxx . . $ _MNE#vect.; ++mne) { |
| 1511 | memcpycxx . . $ memcpy(cc817cb175f282d).(opcode, mne->opcodecxx . . $ _MNE#opcode., sizeof(mne->opcodecxx . . $ _MNE#opcode.)); |
| 1512 | for (i = j = 0; i < NUMOCcxx . . $ NUMOC.; ++i) { |
| 1513 | mne->opcodecxx . . $ _MNE#opcode.[i] = 0; /* not really needed */ |
| 1514 | if (mne->okmaskcxx . . $ _MNE#okmask. & (1L << i)) |
| 1515 | mne->opcodecxx . . $ _MNE#opcode.[i] = opcode[j++]; |
| 1516 | } |
| 1517 | i = hash1cxx . . $ hash1(c61c63047ce273de).(mne->namecxx . . $ _MNE#name.); |
| 1518 | mne->nextcxx . . $ _MNE#next. = MHashcxx . . $ MHash.[i]; |
| 1519 | MHashcxx . . $ MHash.[i] = mne; |
| 1520 | } |
| 1521 | } |
| 1522 | |
| 1523 | |
| 1524 | static unsigned int hash1cxx . . $ hash1(c61c63047ce273de).(const char *str) |
| 1525 | { |
| 1526 | uint8_tcxx . . $ uint8_t# a = 0; |
| 1527 | uint8_tcxx . . $ uint8_t# b = 0; |
| 1528 | while (*str) { // this is Fletcher's checksum, better distribution, faster |
| 1529 | a += *str++; |
| 1530 | b += a; |
| 1531 | } |
| 1532 | return ((((a << 8) & 0xFF00) | (b & 0xFF)) ) & MHASHANDcxx . . $ `src/asm.h:168:9`!; |
| 1533 | } |
| 1534 | |
| 1535 | void pushincludecxx . . $ pushinclude(fda57c8427c60377).(char *str) |
| 1536 | { |
| 1537 | INCFILEcxx . . $ `src/asm.h:156:9`! *inf; |
| 1538 | FILEcxx . . $ FILE# *fi; |
| 1539 | |
| 1540 | if ((fi = pfopencxx . . $ pfopen(82ec0787cd37e0a3).(str, "rb")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1541 | if (F_verbosecxx . . $ F_verbose. > 1 && F_verbosecxx . . $ F_verbose. != 5 ) |
| 1542 | printfcxx . . $ printf(581fddd72a8db8fc).("%.*s Including file \"%s\"\n", Inclevelcxx . . $ Inclevel.*4, "", str); |
| 1543 | ++Inclevelcxx . . $ Inclevel.; |
| 1544 | |
| 1545 | if (F_listfilecxx . . $ F_listfile.) |
| 1546 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(FI_listfilecxx . . $ FI_listfile., "------- FILE %s LEVEL %d PASS %d\n", str, Inclevelcxx . . $ Inclevel., passcxx . . $ pass.); |
| 1547 | |
| 1548 | inf = (INCFILEcxx . . $ `src/asm.h:156:9`! *)zmalloccxx . . $ zmalloc(ff224f080444ee45).(sizeof(INCFILEcxx . . $ `src/asm.h:156:9`!)); |
| 1549 | inf->nextcxx . . $ _INCFILE#next. = pIncfilecxx . . $ pIncfile.; |
| 1550 | inf->namecxx . . $ _INCFILE#name. = strcpycxx . . $ strcpy(b7b3a83273496486).(ckmalloccxx . . $ ckmalloc(ff224f080444ee45).(strlencxx . . $ strlen(751346f8406fd082).(str)+1), str); |
| 1551 | inf->ficxx . . $ _INCFILE#fi. = fi; |
| 1552 | inf->linenocxx . . $ _INCFILE#lineno. = 0; |
| 1553 | pIncfilecxx . . $ pIncfile. = inf; |
| 1554 | return; |
| 1555 | } |
| 1556 | printfcxx . . $ printf(581fddd72a8db8fc).("Warning: Unable to open '%s'\n", str); |
| 1557 | return; |
| 1558 | } |
| 1559 | |
| 1560 | |
| 1561 | |
| 1562 | |
| 1563 | int asmerrcxx . . $ asmerr(1daa6892c969c96d).(int err, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bAbort, const char *sText ) |
| 1564 | { |
| 1565 | const char *str; |
| 1566 | INCFILEcxx . . $ `src/asm.h:156:9`! *pincfile; |
| 1567 | /* file pointer we print error messages to */ |
| 1568 | FILEcxx . . $ FILE# *error_file = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1569 | |
| 1570 | if ( err >= MAX_ERRORcxx . . $ `src/main.c:126:9`! || err < 0 ) |
| 1571 | { |
| 1572 | return asmerrcxx . . $ asmerr(1daa6892c969c96d).( ERROR_BADERRORcxx . . $ ERROR_BADERROR., truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, "Bad error ERROR!" ); |
| 1573 | } |
| 1574 | else |
| 1575 | { |
| 1576 | |
| 1577 | if (sErrorDefcxx . . $ sErrorDef.[err].bFatalcxx . . $ ERRORSTRUCT#bFatal.) |
| 1578 | bStopAtEndcxx . . $ bStopAtEnd.[passcxx . . $ pass.] = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 1579 | |
| 1580 | pincfile = pIncfilecxx . . $ pIncfile.; |
| 1581 | while(1) { |
| 1582 | if (pincfile == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1583 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s:%d: error: pincfile is NULL, err:%d, [%s]: %s\n", __FILE__, __LINE__ |
| 1584 | , err, sText, sErrorDefcxx . . $ sErrorDef.[err].sDescriptioncxx . . $ ERRORSTRUCT#sDescription.); |
| 1585 | bAbort = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 1586 | break; |
| 1587 | } |
| 1588 | if (pincfile->flagscxx . . $ _INCFILE#flags. & INF_MACROcxx . . $ `src/asm.h:267:9`!) { |
| 1589 | pincfile = pincfile->nextcxx . . $ _INCFILE#next.; |
| 1590 | continue; |
| 1591 | } else { |
| 1592 | break; |
| 1593 | } |
| 1594 | } |
| 1595 | str = sErrorDefcxx . . $ sErrorDef.[err].sDescriptioncxx . . $ ERRORSTRUCT#sDescription.; |
| 1596 | |
| 1597 | /* |
| 1598 | New error format selection for 2.20.11 since some |
| 1599 | people *don't* use MS products. For historical |
| 1600 | reasons we currently send errors to stdout when |
| 1601 | they should really go to stderr, but we'll switch |
| 1602 | eventually I hope... [phf] |
| 1603 | */ |
| 1604 | |
| 1605 | /* determine the file pointer to use */ |
| 1606 | error_file = (F_listfilecxx . . $ F_listfile. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? FI_listfilecxx . . $ FI_listfile. : stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!; |
| 1607 | |
| 1608 | /* print first part of message, different formats offered */ |
| 1609 | if (pincfile != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1610 | switch (F_errorformatcxx . . $ F_errorformat.) |
| 1611 | { |
| 1612 | case ERRORFORMAT_WOEcxx . . $ ERRORFORMAT_WOE.: |
| 1613 | /* |
| 1614 | Error format for MS VisualStudio and relatives: |
| 1615 | "file (line): error: string" |
| 1616 | */ |
| 1617 | if(error_file!=stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!) |
| 1618 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(error_file, "%s (%lu): error: ", |
| 1619 | pincfile->namecxx . . $ _INCFILE#name., pincfile->linenocxx . . $ _INCFILE#lineno.); |
| 1620 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(erroradd1cxx . . $ erroradd1., "%s (%lu): error: ", |
| 1621 | pincfile->namecxx . . $ _INCFILE#name., pincfile->linenocxx . . $ _INCFILE#lineno.); // -FXQ |
| 1622 | break; |
| 1623 | case ERRORFORMAT_DILLONcxx . . $ ERRORFORMAT_DILLON.: |
| 1624 | /* |
| 1625 | Matthew Dillon's original format, except that |
| 1626 | we don't distinguish writing to the terminal |
| 1627 | from writing to the list file for now. Matt's |
| 1628 | 2.16 uses these: |
| 1629 | |
| 1630 | "*line %4ld %-10s %s\n" (list file) |
| 1631 | "line %4ld %-10s %s\n" (terminal) |
| 1632 | */ |
| 1633 | if(error_file!=stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!) |
| 1634 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(error_file, "line %7ld %-10s ", |
| 1635 | pincfile->linenocxx . . $ _INCFILE#lineno., pincfile->namecxx . . $ _INCFILE#name.); |
| 1636 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(erroradd1cxx . . $ erroradd1., "line %7ld %-10s ", |
| 1637 | pincfile->linenocxx . . $ _INCFILE#lineno., pincfile->namecxx . . $ _INCFILE#name.); // -FXQ |
| 1638 | break; |
| 1639 | case ERRORFORMAT_GNUcxx . . $ ERRORFORMAT_GNU.: |
| 1640 | /* |
| 1641 | GNU format error messages, from their coding |
| 1642 | standards. |
| 1643 | */ |
| 1644 | if(error_file!=stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!) |
| 1645 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(error_file, "%s:%lu: error: ", |
| 1646 | pincfile->namecxx . . $ _INCFILE#name., pincfile->linenocxx . . $ _INCFILE#lineno.); |
| 1647 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(erroradd1cxx . . $ erroradd1., "%s:%lu: error: ", |
| 1648 | pincfile->namecxx . . $ _INCFILE#name., pincfile->linenocxx . . $ _INCFILE#lineno.); // -FXQ |
| 1649 | break; |
| 1650 | default: |
| 1651 | /* TODO: really panic here? [phf] */ |
| 1652 | paniccxx . . $ panic(85c52e162fed56f9).("Invalid error format, internal error!"); |
| 1653 | break; |
| 1654 | } |
| 1655 | |
| 1656 | if(error_file!=stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!) |
| 1657 | { |
| 1658 | /* print second part of message, always the same for now */ |
| 1659 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(error_file, str, sText ? sText : ""); |
| 1660 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(error_file, "\n"); |
| 1661 | } |
| 1662 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(erroradd2cxx . . $ erroradd2., str, sText ? sText : ""); |
| 1663 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(erroradd3cxx . . $ erroradd3., "\n"); |
| 1664 | |
| 1665 | passbuffer_updatecxx . . $ passbuffer_update(577809987ad7a468).(ERRORBUFcxx . . $ `src/main.c:61:9`!,erroradd1cxx . . $ erroradd1.); |
| 1666 | passbuffer_updatecxx . . $ passbuffer_update(577809987ad7a468).(ERRORBUFcxx . . $ `src/main.c:61:9`!,erroradd2cxx . . $ erroradd2.); |
| 1667 | passbuffer_updatecxx . . $ passbuffer_update(577809987ad7a468).(ERRORBUFcxx . . $ `src/main.c:61:9`!,erroradd3cxx . . $ erroradd3.); |
| 1668 | |
| 1669 | if ( bAbort ) |
| 1670 | { |
| 1671 | passbuffer_outputcxx . . $ passbuffer_output(d4f767463ce0a6b3).(MSGBUFcxx . . $ `src/main.c:62:9`!); // dump messages from this pass |
| 1672 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(error_file, "Aborting assembly\n"); |
| 1673 | passbuffer_outputcxx . . $ passbuffer_output(d4f767463ce0a6b3).(ERRORBUFcxx . . $ `src/main.c:61:9`!); // time to dump the errors from this pass! |
| 1674 | exitcxx . . $ exit(3ca292c338df9bb3).(err); |
| 1675 | } |
| 1676 | } |
| 1677 | |
| 1678 | return err; |
| 1679 | } |
| 1680 | |
| 1681 | char *zmalloccxx . . $ zmalloc(ff224f080444ee45).(int bytes) |
| 1682 | { |
| 1683 | char *ptr = ckmalloccxx . . $ ckmalloc(ff224f080444ee45).(bytes); |
| 1684 | if ( ptr ) |
| 1685 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(ptr, 0, bytes); |
| 1686 | return ptr; |
| 1687 | } |
| 1688 | |
| 1689 | char *ckmalloccxx . . $ ckmalloc(ff224f080444ee45).(int bytes) |
| 1690 | { |
| 1691 | char *ptr = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(bytes); |
| 1692 | if (ptr) |
| 1693 | { |
| 1694 | return ptr; |
| 1695 | } |
| 1696 | paniccxx . . $ panic(85c52e162fed56f9).("unable to malloc"); |
| 1697 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1698 | } |
| 1699 | |
| 1700 | char *permalloccxx . . $ permalloc(ff224f080444ee45).(int bytes) |
| 1701 | { |
| 1702 | static char *buf; |
| 1703 | static int left; |
| 1704 | char *ptr; |
| 1705 | |
| 1706 | /* Assume sizeof(union align) is a power of 2 */ |
| 1707 | |
| 1708 | union aligncxx . . $ permalloc(ff224f080444ee45).align# |
| 1709 | { |
| 1710 | long lcxx . . $ permalloc(ff224f080444ee45).align#l.; |
| 1711 | void *pcxx . . $ permalloc(ff224f080444ee45).align#p.; |
| 1712 | void (*fpcxx . . $ permalloc(ff224f080444ee45).align#fp.)(void); |
| 1713 | }; |
| 1714 | |
| 1715 | bytes = (bytes + sizeof(union aligncxx . . $ permalloc(ff224f080444ee45).align#)-1) & ~(sizeof(union aligncxx . . $ permalloc(ff224f080444ee45).align#)-1); |
| 1716 | if (bytes > left) |
| 1717 | { |
| 1718 | if ((buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(ALLOCSIZEcxx . . $ `src/asm.h:169:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1719 | paniccxx . . $ panic(85c52e162fed56f9).("unable to malloc"); |
| 1720 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(buf, 0, ALLOCSIZEcxx . . $ `src/asm.h:169:9`!); |
| 1721 | left = ALLOCSIZEcxx . . $ `src/asm.h:169:9`!; |
| 1722 | if (bytes > left) |
| 1723 | paniccxx . . $ panic(85c52e162fed56f9).("software error"); |
| 1724 | } |
| 1725 | ptr = buf; |
| 1726 | buf += bytes; |
| 1727 | left -= bytes; |
| 1728 | return ptr; |
| 1729 | } |
| 1730 | |
| 1731 | char *strlowercxx . . $ strlower(7a9722d75b371431).(char *str) |
| 1732 | { |
| 1733 | char c; |
| 1734 | char *ptr; |
| 1735 | |
| 1736 | for (ptr = str; (c = *ptr); ++ptr) |
| 1737 | { |
| 1738 | if (c >= 'A' && c <= 'Z') |
| 1739 | *ptr = c | 0x20; |
| 1740 | } |
| 1741 | return str; |
| 1742 | } |
| 1743 | |
| 1744 | int maincxx . . $ main(afcd3168fc1188a4).(int ac, char **av) |
| 1745 | { |
| 1746 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bTableSort = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 1747 | int nError = MainShadowcxx . . $ MainShadow(99b3d3d4c05154e4).( ac, av, &bTableSort ); |
| 1748 | |
| 1749 | if ( nError && (nError != ERROR_NON_ABORTcxx . . $ ERROR_NON_ABORT.) ) |
| 1750 | { |
| 1751 | // dump messages when aborting due to errors |
| 1752 | passbuffer_outputcxx . . $ passbuffer_output(d4f767463ce0a6b3).(MSGBUFcxx . . $ `src/main.c:62:9`!); |
| 1753 | |
| 1754 | // Only print errors if assembly is unsuccessful |
| 1755 | passbuffer_outputcxx . . $ passbuffer_output(d4f767463ce0a6b3).(ERRORBUFcxx . . $ `src/main.c:61:9`!); |
| 1756 | |
| 1757 | printfcxx . . $ printf(581fddd72a8db8fc).( "Fatal assembly error: %s\n", sErrorDefcxx . . $ sErrorDef.[nError].sDescriptioncxx . . $ ERRORSTRUCT#sDescription. ); |
| 1758 | } |
| 1759 | |
| 1760 | DumpSymbolTablecxx . . $ DumpSymbolTable(b45ddcbc8423892c).( bTableSort ); |
| 1761 | |
| 1762 | passbuffer_cleanupcxx . . $ passbuffer_cleanup(49f6e7a06ebc5aa8).(); |
| 1763 | |
| 1764 | if (nError != 0) { |
| 1765 | if (bRemoveOutBincxx . . $ bRemoveOutBin.) { |
| 1766 | unlinkcxx . . $ unlink(5c4306d8553b3696).(F_outfilecxx . . $ F_outfile.); |
| 1767 | } |
| 1768 | } |
| 1769 | return nError; |
| 1770 | } |
| 1771 | |
| 1772 | void passbuffer_clearcxx . . $ passbuffer_clear(d4f767463ce0a6b3).(int mbindex) |
| 1773 | { |
| 1774 | // ensure the buffer is initialized before we attempt to clear it, |
| 1775 | // just in case no messages have been stored prior to this clear. |
| 1776 | if(passbuffercxx . . $ passbuffer.[mbindex] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1777 | passbuffer_updatecxx . . $ passbuffer_update(577809987ad7a468).(mbindex,""); |
| 1778 | // clear the requested guffer |
| 1779 | passbuffercxx . . $ passbuffer.[mbindex][0] = 0; |
| 1780 | } |
| 1781 | |
| 1782 | void passbuffer_updatecxx . . $ passbuffer_update(577809987ad7a468).(int mbindex,char *message) |
| 1783 | { |
| 1784 | int newsizerequired; |
| 1785 | |
| 1786 | // allocate 16k buffers to start... |
| 1787 | static int passbuffersize[2] = {16384,16384}; |
| 1788 | |
| 1789 | |
| 1790 | // check if the buffer we're working with needs initialization |
| 1791 | if(passbuffercxx . . $ passbuffer.[mbindex] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1792 | { |
| 1793 | passbuffercxx . . $ passbuffer.[mbindex] = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(passbuffersize[mbindex]); |
| 1794 | if(passbuffercxx . . $ passbuffer.[mbindex] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1795 | paniccxx . . $ panic(85c52e162fed56f9).("couldn't allocate memory for message buffer."); |
| 1796 | passbuffercxx . . $ passbuffer.[mbindex][0] = 0; // empty string |
| 1797 | } |
| 1798 | |
| 1799 | // check if we need to grow the buffer... |
| 1800 | newsizerequired=strlencxx . . $ strlen(751346f8406fd082).(passbuffercxx . . $ passbuffer.[mbindex])+strlencxx . . $ strlen(751346f8406fd082).(message); |
| 1801 | if( newsizerequired > passbuffersize[mbindex]) |
| 1802 | { |
| 1803 | // double the current buffer size, if sufficient, so we don't continually reallocate memory... |
| 1804 | newsizerequired = ( newsizerequired < (passbuffersize[mbindex]*2) ) ? passbuffersize[mbindex]*2 : newsizerequired; |
| 1805 | |
| 1806 | //fprintf(stderr,"DEBUG: growing buffer %d to %d bytes\n", mbindex, newsizerequired); |
| 1807 | |
| 1808 | passbuffercxx . . $ passbuffer.[mbindex] = realloccxx . . $ realloc(417ab160f6baadc6).(passbuffercxx . . $ passbuffer.[mbindex], newsizerequired); |
| 1809 | if(passbuffercxx . . $ passbuffer.[mbindex] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1810 | paniccxx . . $ panic(85c52e162fed56f9).("couldn't grow memory for message buffer."); |
| 1811 | passbuffersize[mbindex]=newsizerequired; |
| 1812 | } |
| 1813 | |
| 1814 | // update the buffer with the message... |
| 1815 | strcatcxx . . $ strcat(b7b3a83273496486).(passbuffercxx . . $ passbuffer.[mbindex],message); |
| 1816 | } |
| 1817 | |
| 1818 | void passbuffer_outputcxx . . $ passbuffer_output(d4f767463ce0a6b3).(int mbindex) |
| 1819 | { |
| 1820 | // ensure the buffer is initialized before we attempt to clear it, |
| 1821 | // just in case no messages have been stored yet. |
| 1822 | if(passbuffercxx . . $ passbuffer.[mbindex] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1823 | passbuffer_updatecxx . . $ passbuffer_update(577809987ad7a468).(mbindex,""); |
| 1824 | printfcxx . . $ printf(581fddd72a8db8fc).("%s\n",passbuffercxx . . $ passbuffer.[mbindex]); // ...do we really still need to put this through stdout, instead stderr? |
| 1825 | } |
| 1826 | |
| 1827 | void passbuffer_cleanupcxx . . $ passbuffer_cleanup(49f6e7a06ebc5aa8).() |
| 1828 | { |
| 1829 | int t; |
| 1830 | for(t=0;t<2;t++) |
| 1831 | if(passbuffercxx . . $ passbuffer.[t]!=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1832 | freecxx . . $ free(5d22bdacc48458e8).(passbuffercxx . . $ passbuffer.[t]); |
| 1833 | } |