home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / vbcc / pasm / ppcasm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-17  |  21.7 KB  |  618 lines

  1. /* $VER: pasm ppcasm.h V0.8 (14.02.98)
  2.  *
  3.  * This file is part of pasm, a portable PowerPC assembler.
  4.  * Copyright (c) 1997-98  Frank Wille
  5.  *
  6.  * pasm is freeware and part of the portable and retargetable ANSI C
  7.  * compiler vbcc, copyright (c) 1995-98 by Volker Barthelmann.
  8.  * pasm may be freely redistributed as long as no modifications are
  9.  * made and nothing is charged for it. Non-commercial usage is allowed
  10.  * without any restrictions.
  11.  * EVERY PRODUCT OR PROGRAM DERIVED DIRECTLY FROM MY SOURCE MAY NOT BE
  12.  * SOLD COMMERCIALLY WITHOUT PERMISSION FROM THE AUTHOR.
  13.  *
  14.  *
  15.  * v0.8 (14.02.98) phx
  16.  *      Alignment list for each section. This fixes the problems
  17.  *      with optimizations.
  18.  * v0.7 (02.01.98) phx
  19.  *      Define "NetBSDAmiga68k" changed to "NetBSD68k".
  20.  *      Changed ParsedLine (next) and GlobalVars (anotherpass) to
  21.  *      allow more than two assembler passes - as required for
  22.  *      optimizations.
  23.  *      search_instr() is global.
  24.  *      Output format 3 is ADOS (like EHF, but doesn't use HUNK_PPC_CODE).
  25.  * v0.6 (30.10.97) phx
  26.  *      More options. GlobalVars: optinstrmode and supermode.
  27.  * v0.5 (12.10.97) phx
  28.  *      Add userdeflist and usrdefs to GlobalVars for symbol definitions
  29.  *      via the command line.
  30.  *      .set allows symbols to be reused.
  31.  *      Last line of a source text was ignored, if newline is missing.
  32.  * v0.4 (05.07.97) phx
  33.  *      Program returns EXIT_FAILURE if an error occurs.
  34.  *      Base address for absolute code may be set with -B option.
  35.  *      EHF support.
  36.  *      Added R_PPC_TOC16 relocation type.
  37.  *      Option -x automatically declares unknown symbols as
  38.  *      externally defined. New GlobalVars entry: autoextern.
  39.  *      Runs on Linux/DEC-Alpha with 64-bit integers.
  40.  *      Changed program name from "PPCasm" to "pasm". Reason: There
  41.  *      is already a PPCasm for Apple Macintosh.
  42.  * v0.3 (20.04.97) phx
  43.  *      Using correct names for PowerPC relocations.
  44.  *      Added little-endian conversion macros.
  45.  * v0.2 (25.03.97) phx
  46.  *      Writes ELF object for 32-bit PowerPC big-endian. Either absolute
  47.  *      or ELF output format may be selected. ELF is default for all
  48.  *      currently supported platforms. PPCasm supports nine different
  49.  *      relocation types (there are much more...).
  50.  *      Compiles and works also under NetBSD/amiga (68k).
  51.  *      Changed function declaration to 'new style' in all sources
  52.  *      (to avoid problems with '...' for example).
  53.  *      Included NetBSD/amiga as supported architecture.
  54.  * v0.1 (11.03.97) phx
  55.  *      First test version with all PowerPC instructions and most
  56.  *      important directives. Only raw, absolute output.
  57.  * v0.0 (14.02.97) phx
  58.  *      File created. Project started.
  59.  */
  60.  
  61. #include <stdlib.h>
  62. #include <stdio.h>
  63. #include <string.h>
  64. #include <stdarg.h>
  65. #include <ctype.h>
  66.  
  67. /* program's name */
  68. #define PNAME "pasm"
  69.  
  70. /* version/revision */
  71. #define VERSION 0
  72. #define REVISION 80
  73.  
  74. /* architecture specific defines */
  75. #if defined (AmigaOS68k)
  76. #define MACHINE "Amiga OS/M68k"
  77. #define BIGENDIAN
  78. #define STDTYPES
  79. #elif defined (AmigaOSPPC)
  80. #define MACHINE "Amiga OS/PowerPC"
  81. #define BIGENDIAN
  82. #define STDTYPES
  83. #elif defined (NetBSD68k)
  84. #define MACHINE "NetBSD/M68k"
  85. #define BIGENDIAN
  86. #define STDTYPES
  87. #elif defined (SolarisSparc)
  88. #define MACHINE "Solaris/Sparc"
  89. #define BIGENDIAN
  90. #define STDTYPES
  91. #elif defined (SunOSSparc)
  92. #define MACHINE "SunOS/Sparc"
  93. #define BIGENDIAN
  94. #define STDTYPES
  95. #elif defined (SCOi386)
  96. #define MACHINE "SCO/i386"
  97. #define LITTLEENDIAN
  98. #define STDTYPES
  99. #elif defined (Linuxi386)
  100. #define MACHINE "Linux/i386"
  101. #define LITTLEENDIAN
  102. #define STDTYPES
  103. #elif defined (LinuxAlpha)
  104. #define MACHINE "Linux/Alpha"
  105. #define LITTLEENDIAN
  106. #define TYPES64BIT
  107. #else
  108. #error Unsupported architecture! Please adapt the source text.
  109. #endif
  110.  
  111. #ifdef STDTYPES
  112. typedef signed char int8;
  113. typedef unsigned char uint8;
  114. typedef signed short int int16;
  115. typedef unsigned short int uint16;
  116. typedef signed long int int32;
  117. typedef unsigned long int uint32;
  118. typedef signed char bool;
  119. #elif defined (TYPES64BIT)
  120. typedef signed char int8;
  121. typedef unsigned char uint8;
  122. typedef signed short int16;
  123. typedef unsigned short uint16;
  124. typedef signed int int32;
  125. typedef unsigned int uint32;
  126. typedef int bool;
  127. #else
  128. #error Unsupported architecture! Please adapt the source text.
  129. #endif
  130.  
  131. /* endian conversion */
  132. #if defined (BIGENDIAN)
  133. #define ECH(x) x
  134. #define ECW(x) x
  135. #define ECVH(x) x
  136. #define ECVW(x) x
  137. #elif defined (LITTLEENDIAN)
  138. #define ECH(x) (((x)&0xff)<<8|((x)&0xff00)>>8)
  139. #define ECW(x) (((x)&0xff)<<24|((x)&0xff00)<<8|((x)&0xff0000)>>8|((x)&0xff000000)>>24)
  140. #define ECVH(x) l2bh(x)
  141. #define ECVW(x) l2bw(x)
  142. #else
  143. #error You have to define either BIGENDIAN or LITTLEENDIAN.
  144. #endif
  145.  
  146.  
  147. /* program constants */
  148.  
  149. #ifndef TRUE
  150. #define TRUE 1
  151. #endif
  152. #ifndef FALSE
  153. #define FALSE 0
  154. #endif
  155. #ifndef NULL
  156. #define NULL 0
  157. #endif
  158.  
  159. #define FNAMEBUFSIZE 1024       /* buffer size for file names */
  160. #define EXPSTACKSIZE 32         /* maximum arguments in an expression */
  161.  
  162.  
  163. /* structures */
  164.  
  165. struct node {
  166.   struct node *next;
  167.   struct node *pred;
  168. };
  169.  
  170. struct list {
  171.   struct node *first;
  172.   struct node *dummy;
  173.   struct node *last;
  174. };
  175.  
  176. struct CPUInstr {
  177.   struct CPUInstr *hash_chain;  /* next instruction in hash chain */
  178.   char *name;                   /* instruction's name */
  179.   uint16 flags;                 /* format flags */
  180.   uint8 type;                   /* instruction format, see defines */
  181.   uint8 opcd;                   /* opcode (bit 0-5) */
  182.   uint8 fieldD;                 /* preset D field (bit 6-10) */
  183.   uint8 fieldA;                 /* preset D field (bit 11-15) */
  184.   uint16 xo;                    /* extended opcode (bit 21-31) */
  185. };
  186. /* CPU instruction formats */
  187. #define T_I 0                   /* Bx */
  188. #define T_B 1                   /* BCx */
  189. #define T_DD 2                  /* LWZ */
  190. #define T_DI 3                  /* ADDI */
  191. #define T_DS 4                  /* LD */
  192. #define T_X 5                   /* AND */
  193. #define T_IMM 6                 /* MTFSFI */
  194. #define T_XLB 7                 /* BCLRx */
  195. #define T_XSPR 8                /* MFSPR */
  196. #define T_XCRM 9                /* MTCRF */
  197. #define T_XFL 10                /* MTFSF */
  198. #define T_XS 11                 /* SRADIx */
  199. #define T_A 12                  /* FMADDx */
  200. #define T_M 13                  /* RLWIMIx */
  201. #define T_MD 14                 /* RLDICx */
  202. #define T_CMP 15                /* CMP */
  203. /* CPU instruction flags */
  204. #define F_SUPP_D 0x01           /* D = 0 */
  205. #define F_SUPP_A 0x02           /* A = 0 */
  206. #define F_SUPP_B 0x04           /* B = 0 */
  207. #define F_SUPP_C 0x08           /* C = 0 */
  208. #define F_CRF_D 0x10            /* D = CR field */
  209. #define F_CRF_S 0x20            /* S = CR field */
  210. #define F_SWAP 0x40             /* S instr.: D = S, A and S are swapped */
  211. #define F_SIGNED 0x80           /* 16 bit signed immediate */
  212. #define F_64BIT 0x100           /* 64 bit instruction */
  213. #define F_SUPER 0x200           /* supervisor-only instruction */
  214. #define F_OPTIONAL 0x400        /* optional instruction */
  215. #define F_EXTENDED 0x8000       /* extended mnemonic */
  216.  
  217. struct Directive {
  218.   struct Directive *hash_chain; /* next directive in hash chain */
  219.   char *name;                   /* directive's name */
  220.   void (*dfunct)();
  221. };
  222.  
  223. struct Macro {
  224.   struct Macro *hash_chain;     /* next macro in hash chain */
  225.   char *name;                   /* macro's name */
  226.   char *text;                   /* ptr to first macro line */
  227.   unsigned long nlines;         /* number of lines in this macro */
  228. };
  229.  
  230. struct AlignPoint {             /* defines an alignment point (.align) */
  231.   struct AlignPoint *next;
  232.   unsigned long offset;         /* section offset for alignent */
  233.   long val;                     /* alignment value */
  234.   long gap;                     /* current alignment gap */
  235. };
  236.  
  237. struct Section {
  238.   struct node n;
  239.   char *name;                   /* section's name */
  240.   uint8 type;                   /* type: code, data, bss, offsets, ... */
  241.   uint8 flags;
  242.   uint8 protection;             /* readable, writable, executable, ... */
  243.   uint8 alignment;              /* number of bits, which have to be zero */
  244.   unsigned long pc;             /* current program counter (sect. offset) */
  245.   unsigned long size;           /* size of section in bytes */
  246.   void *contents;               /* contents, allocated in pass 2 */
  247.   void *data;
  248.   struct AlignPoint *first_align;    /* pointer to first alignment point */
  249.   struct AlignPoint *current_align;  /* current alignment point */
  250.   struct list reloclist;        /* section offsets to relocate */
  251.   struct list xreflist;         /* external references in this section */
  252.   uint32 index;                 /* e.g. section header index for ELF */
  253. };
  254. /* section types */
  255. #define ST_UNDEFINED 0
  256. #define ST_CODE 1               /* section contains code */
  257. #define ST_DATA 2               /* section contains initialized data */
  258. #define ST_UDATA 3              /* section contains uninitialized data */
  259. #define ST_STRUCT 4             /* offset section (will be discarded) */
  260. /* section flags */
  261. #define SF_DISCARD 1            /* can be discarded (e.g. ST_STRUCT) */
  262. #define SF_UNINITIALIZED 2      /* section has uninitialized contents */
  263. /* protection */
  264. #define SP_READ 1
  265. #define SP_WRITE 2
  266. #define SP_EXEC 4
  267. #define SP_SHARE 8
  268.  
  269. struct Symbol {
  270.   struct Symbol *hash_chain;    /* next symbol in hash chain */
  271.   char *name;                   /* symbol's name */
  272.   uint32 value;                 /* absolute value or relocation offset */
  273.   struct Section *relsect;      /* symbol def. relative to this section */
  274.   struct AlignPoint *alignpoint;/* sym. was defined after this aligment */
  275.   uint8 type;                   /* absolute, relocatable or extern */
  276.   uint8 flags;
  277.   uint8 info;                   /* section, function or object */
  278.   uint8 bind;                   /* local or global */
  279.   uint32 size;                  /* object's size in bytes */
  280. };
  281. /* symbol type */
  282. #define SYM_UNDEF 0
  283. #define SYM_ABS 1
  284. #define SYM_RELOC 2
  285. #define SYM_EXTERN 3
  286. /* object type */
  287. #define SYMI_NOTYPE 0
  288. #define SYMI_OBJECT 1
  289. #define SYMI_FUNC 2
  290. #define SYMI_SECTION 3
  291. #define SYMI_FILE 4
  292. /* symbol bind */
  293. #define SYMB_NONE 0
  294. #define SYMB_LOCAL 1
  295. #define SYMB_GLOBAL 2
  296. #define SYMB_WEAK 3
  297.  
  298. struct Reloc {
  299.   struct node n;
  300.   unsigned long offset;         /* section-offset of relocation */
  301.   uint32 addend;                /* add this to relocation value */
  302.   struct Section *relocsect;    /* base addr of this sect. has to be added */
  303.   uint8 type;
  304. };
  305. /* reloc types (identical with the reloc types used for ELF) */
  306. #define R_NONE 0
  307. #define R_PPC_ADDR32 1          /* 32-bit relocation */
  308. #define R_PPC_ADDR24 2          /* 26-bit relocation for B-instruction */
  309. #define R_PPC_ADDR16 3          /* 16-bit relocation */
  310. #define R_PPC_ADDR16_LO 4       /* relocation of the lower half-word */
  311. #define R_PPC_ADDR16_HI 5       /* relocation of the higher half-word */
  312. #define R_PPC_ADDR16_HA 6       /* higher half-word reloc. for ADDI */
  313. #define R_PPC_ADDR14 7          /* BC-instruction, 16-bit absolute */
  314. #define R_PPC_ADDR14_BRTAKEN 8
  315. #define R_PPC_ADDR14_BRNTAKEN 9
  316. #define R_PPC_REL24 10          /* relative 26-bit (PowerPC B-instruction) */
  317. #define R_PPC_REL14 11          /* BC-instruction, 16-bit relative */
  318. #define R_PPC_REL14_BRTAKEN 12
  319. #define R_PPC_REL14_BRNTAKEN 13
  320. #define R_PPC_GOT16 14
  321. #define R_PPC_GOT16_LO 15
  322. #define R_PPC_GOT16_HI 16
  323. #define R_PPC_GOT16_HA 17
  324. #define R_PPC_PLTREL24 18
  325. #define R_PPC_COPY 19
  326. #define R_PPC_GLOB_DAT 20
  327. #define R_PPC_JMP_SLOT 21
  328. #define R_PPC_RELATIVE 22
  329. #define R_PPC_LOCAL24PC 23
  330. #define R_PPC_UADDR32 24
  331. #define R_PPC_UADDR16 25
  332. #define R_PPC_REL32 26          /* section base offset */
  333. #define R_PPC_PLT32 27
  334. #define R_PPC_PLTREL32 28
  335. #define R_PPC_PLT16_LO 29
  336. #define R_PPC_PLT16_HI 30
  337. #define R_PPC_PLT16_HA 31
  338. #define R_PPC_SDAREL16 32
  339. #define R_PPC_SECTOFF 33
  340. #define R_PPC_SECTOFF_LO 34
  341. #define R_PPC_SECTOFF_HI 35
  342. #define R_PPC_SECTOFF_HA 36
  343. #define R_PPC_TOC16 255
  344.  
  345. struct XReference {
  346.   struct node n;
  347.   struct Symbol *xsymbol;       /* external symbol, which is referenced */
  348.   unsigned long offset;
  349.   uint32 addend;
  350.   uint8 type;                   /* relocation type, see struct Reloc */
  351.   uint8 size;                   /* size of reference in bytes (3 = 26bit) */
  352. };
  353.  
  354. struct ParsedLine {
  355.   uint8 type;                   /* opcode type */
  356.   uint8 flags;
  357.   int8 branch_hint;             /* 0=no hint, 1=b. taken(+), -1=not taken(-)*/
  358.   uint8 narg;                   /* value for $NARG, when calling macro */
  359.   char *lineptr;                /* ptr to source text line */
  360.   void *opcode;                 /* ptr to CPUInstr, Directive or SourceText */
  361.   char *operand;                /* ptr to operand-string */
  362.   struct ParsedLine *next;      /* pasm added another opcode here, if != 0 */
  363. };
  364. /* opcode types */
  365. #define OT_IGNORE 0             /* line is empty or commented out */
  366. #define OT_INSTRUCTION 1
  367. #define OT_DIRECTIVE 2
  368. #define OT_MACRO 3
  369. #define OT_SECTION 4
  370. /* flags */
  371. #define PLF_NONEWLINE 1         /* new statement is still part of same line */
  372. #define PLF_ALIGN 2
  373.  
  374. struct SourceText {             /* start address and size of all text files */
  375.   struct node n;
  376.   char *name;                   /* name of source, include file or macro */
  377.   char *text;                   /* source text pointer */
  378.   unsigned long nlines;         /* number of lines in source text */
  379.   struct ParsedLine *plin;      /* ParsedLine structures for nlines */
  380. };
  381.  
  382. #define MAX_MACPARAMS 10        /* macro parameters \0-\9 */
  383. struct MacroParams {
  384.   char *param[MAX_MACPARAMS];   /* parameter strings, which replace \x */
  385.   uint32 call_id;               /* macro call id */
  386.   uint32 narg;                  /* number of arguments */
  387.   char param0[2];               /* parameter 0 contains the branch hint */
  388. };
  389.  
  390. struct SourceThread {           /* main source, includes and macros */
  391.   struct SourceThread *prev;    /* previous source thread */
  392.   struct MacroParams *macro;    /* only assigned in macro mode */
  393.   struct SourceText *csource;   /* ptr to current source text node */
  394.   char *lineptr;                /* source text pointer to current line */
  395.   char *srcptr;                 /* current source text pointer */
  396.   unsigned long line;           /* current line inside this thread */
  397.   struct Macro *macskip;        /* indicates macro skip mode */
  398. };
  399.  
  400. struct Expression {
  401.   uint32 value;
  402.   uint8 type;                   /* same type definitions as used for Symbol */
  403.   uint8 reloctype;              /* see struct Reloc */
  404.   struct Symbol *symbol;        /* reloc or extern symbol, used in exp. */
  405. };
  406.  
  407. struct UserDefine {
  408.   struct node n;
  409.   char *line;                   /* .set <symbol>,<assignment> */
  410. };
  411.  
  412.  
  413. #define DEF_MAXERRORS 5
  414. #define MAX_INCPATHS 8
  415. #define MAX_IFLEVELS 16
  416. #define LINEBUFSIZE 1024
  417. #define STRBUFSIZE 256
  418. /* number of entries in hash tables */
  419. #define SYMHTABSIZE 0x4000      /* symbol hash table */
  420. #define INSTRHTABSIZE 0x1000    /* instruction hash table */
  421. #define DIRHTABSIZE 0x800       /* directive hash table */
  422. #define MACROHTABSIZE 0x800     /* macro hash table */
  423. /* supported output formats */
  424. #define OFMT_ABSOLUTE 0
  425. #define OFMT_ELF 1
  426. #define OFMT_EHF 2
  427. #define OFMT_ADOS 3
  428. #define OFMT_LAST 3
  429. /* optimization flags */
  430. #define OPT_FAR_BRANCH 0x00010000
  431. /* "Bcc label" with destination out of range will be converted into a */
  432. /* "B!cc *+8/B label" combination. */
  433.  
  434. struct GlobalVars {
  435.   char *source_name;            /* source text file name */
  436.   char *dest_name;              /* output file name */
  437.  
  438.   /* options */
  439.   bool dontwarn;                /* suppress warnings */
  440.   bool noregsymbols;            /* don't predefine register symbols etc. */
  441.   bool noextmnemo;              /* no extended mnemonics */
  442.   bool sixtyfourmode;           /* 64-bit mode activated */
  443.   bool optinstrmode;            /* optional instructions */
  444.   bool supermode;               /* supervisor mode instructions */
  445.   bool autoextern;              /* autom. declare undef. sym. as extern */
  446.   uint8 output;                 /* output format */
  447.   uint32 opt;                   /* optimization flags */
  448.   struct list userdeflist;      /* user defines */
  449.   bool usrdefs;
  450.  
  451.   int maxerrors;                /* # of errors to display, before aborting */
  452.   int errcnt;                   /* number of errors displayed */
  453.   int returncode;               /* return code for exit() */
  454.   char *incpaths[MAX_INCPATHS]; /* paths where to search for files */
  455.   char *ident;                  /* unit identification or comment */
  456.   char *file;                   /* source file name for debugging */
  457.   unsigned long absbase;        /* base address for absolute code */
  458.   struct list sourcelist;       /* source text list */
  459.   struct list sectionlist;      /* defined sections */
  460.  
  461.   struct SourceThread *cthread; /* current source thread */
  462.   struct Section *csect;        /* current section */
  463.   struct Symbol *lcsym;         /* location counter symbol '$' */
  464.   struct Symbol *nargsym;       /* symbol for number of arguments '$NARG' */
  465.   struct SourceText *srctxtp;   /* source text pointer for get_source() */
  466.   uint32 macrocnt;              /* incremented on every macro invocation */
  467.   unsigned long absline;        /* absolute line number */
  468.   uint8 pass;                   /* 0 or 1 */
  469.   uint8 iflevel;                /* current level for conditional assembly */
  470.   uint8 ifignore;               /* number of else/endifs to ignore */
  471.   bool ifcond[MAX_IFLEVELS];    /* ifcond[0] is always TRUE */
  472.   bool signedexp;               /* current expression to eval is signed */
  473.   bool alignflag,vc;
  474.   bool anotherpass;             /* true, if another pass is required */
  475.  
  476.   /* TOC */
  477.   int rtoc;                     /* register number for toc-mode */
  478.   struct Section *tocsect;      /* ptr to TOC section, or NULL */
  479.  
  480.   /* hash tables */
  481.   struct Symbol **symbols;      /* symbol hash table */
  482.   struct CPUInstr **instr;      /* instruction hash table */
  483.   struct Directive **directives; /* directive hash table */
  484.   struct Macro **macros;        /* macro hash table */
  485.  
  486.   /* buffers */
  487.   char linebuf[LINEBUFSIZE];    /* buffer for a whole source text line */
  488.   char strbuf[STRBUFSIZE];      /* string buffer for labels, opcodes, etc. */
  489.   uint8 alignment_bytes[4];     /* four zero bytes */
  490. };
  491.  
  492.  
  493. /* global functions */
  494.  
  495. /* main.c */
  496. #ifndef MAIN_C
  497. extern struct GlobalVars gvars;
  498. extern void cleanup(struct GlobalVars *);
  499. #endif
  500.  
  501. /* version.c */
  502. #ifndef VERSION_C
  503. extern void show_version(void);
  504. extern void show_usage(void);
  505. #endif
  506.  
  507. /* pass.c */
  508. #ifndef PASS_C
  509. extern void exec_pass1(struct GlobalVars *);
  510. extern void pass1(struct GlobalVars *,struct SourceText *,
  511.                   struct MacroParams *,struct SourceThread *);
  512. extern struct SourceText *include_source(struct GlobalVars *,char *);
  513. extern void exec_pass2(struct GlobalVars *);
  514. extern void pass2(struct GlobalVars *,struct SourceText *,
  515.                   struct MacroParams *,struct SourceThread *);
  516. extern struct SourceText *get_source(struct GlobalVars *);
  517. #endif
  518.  
  519. /* support.c */
  520. #ifndef SUPPORT_C
  521. extern void *alloc(size_t);
  522. extern void *alloczero(size_t);
  523. extern char *allocstring(char *);
  524. extern void initlist(struct list *);
  525. extern void addtail(struct list *,struct node *);
  526. extern struct node *remhead(struct list *);
  527. extern struct node *remnode(struct node *);
  528. extern char *mapfile(struct GlobalVars *,char *);
  529. extern void checkrange(uint32,int,bool);
  530. extern void lower_case(char *);
  531. #ifdef LITTLEENDIAN
  532. extern uint16 l2bh(uint16);
  533. extern uint32 l2bw(uint32);
  534. #endif
  535. #endif
  536.  
  537. /* eval.c */
  538. #ifndef EVAL_C
  539. extern char *getsymbol(struct GlobalVars *,char *);
  540. extern char *getarg(struct GlobalVars *,char *);
  541. extern char *skipspaces(char *);
  542. extern char *remquotes(char *);
  543. extern void checkEOL(char *);
  544. extern char *skipexpression(struct GlobalVars *,char *);
  545. extern void read_macro_params(struct GlobalVars *,struct ParsedLine *,
  546.                               struct MacroParams *,char *);
  547. extern char *getexp(struct GlobalVars *,char *,uint32 *,uint8);
  548. extern uint32 makereloc(struct GlobalVars *,struct Expression *);
  549. extern uint32 makexref(struct GlobalVars *,struct Expression *,uint8);
  550. extern char *getintexp(struct GlobalVars *,char *,uint32 *);
  551. extern char *eval_expression(struct GlobalVars *,struct Expression *,char *);
  552. #endif
  553.  
  554. /* tables.c */
  555. #ifndef TABLES_C
  556. extern void init_hashtables(struct GlobalVars *);
  557. extern void add_macro(struct GlobalVars *,struct Macro *);
  558. extern struct Symbol *add_symbol(struct GlobalVars *,char *,uint8,uint32);
  559. extern struct CPUInstr *search_instr(struct GlobalVars *,char *);
  560. extern unsigned long elf_hash(unsigned char *);
  561. extern struct Symbol *search_symbol(struct GlobalVars *,char *);
  562. extern struct Section *search_section(struct GlobalVars *,char *);
  563. extern void search_opcode(struct GlobalVars *,struct ParsedLine *,
  564.                           char *,char *);
  565. #endif
  566.  
  567. /* errors.c */
  568. #ifndef ERRORS_C
  569. extern void error(int,...);
  570. extern void ierror(char *,...);
  571. #endif
  572.  
  573. /* predefs.c */
  574. extern char stdsects[];
  575. extern char stdsets[];
  576. extern char *xmnemos[];
  577.  
  578. /* elfrelocnames.c */
  579. extern char *elfrel_name[];
  580. #define ELFRELNAMMSK 0x3f  /* number of names in elfrel_name[] minus 1 */
  581.  
  582. /* instructions.c */
  583. #ifndef INSTRUCTIONS_C
  584. extern struct CPUInstr instructions[];
  585. extern void instr(struct GlobalVars *,struct ParsedLine *);
  586. extern char *check_comma(char *);
  587. extern void pcadd(struct GlobalVars *,unsigned long);
  588. extern void store_byte(struct GlobalVars *,uint8);
  589. extern void store_half(struct GlobalVars *,uint16);
  590. extern void store_word(struct GlobalVars *,uint32);
  591. extern void store_float(struct GlobalVars *,double);
  592. extern void store_double(struct GlobalVars *,double);
  593. extern void store_space(struct GlobalVars *,unsigned long);
  594. #endif
  595.  
  596. /* directives.c */
  597. #ifndef DIRECTIVES_C
  598. extern struct Directive directives[];
  599. extern void activate_section(struct GlobalVars *,struct Section *);
  600. extern void alignment(struct GlobalVars *,unsigned long);
  601. extern char escchar(char);
  602. #endif
  603.  
  604. /* output_abs.c */
  605. #ifndef OUTPUT_ABS_C
  606. extern void output_absolute(struct GlobalVars *);
  607. #endif
  608.  
  609. /* output_elf.c */
  610. #ifndef OUTPUT_ELF_C
  611. extern void output_elf32msb(struct GlobalVars *);
  612. #endif
  613.  
  614. /* output_ehf.c */
  615. #ifndef OUTPUT_EHF_C
  616. extern void output_ehf(struct GlobalVars *);
  617. #endif
  618.