Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!inria!litp!pda From: pda@litp.ibp.fr (Pierre DAVID) Newsgroups: comp.sys.handhelds Subject: Saturn Assembler (Part 7/8) Message-ID: <3308@litp.ibp.fr> Date: 5 Jul 90 16:25:56 GMT Reply-To: pda@litp.ibp.fr.UUCP (Pierre DAVID) Organization: M.A.S.I., Universite P. & M. Curie, Paris, FRANCE Lines: 2159 #---------------------------------- cut here ---------------------------------- # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by Pierre David on Sun Jul 1 12:33:05 1990 # # This archive contains: # areuh/assembler/aopc2.c areuh/assembler/apass.c # areuh/assembler/areport.c areuh/assembler/autil.c # areuh/assembler/common.h areuh/assembler/err.h # areuh/assembler/exp.c areuh/assembler/flag.h # # Error checking via wc(1) will be performed. LANG=""; export LANG PATH=/bin:/usr/bin:$PATH; export PATH echo x - areuh/assembler/aopc2.c cat >areuh/assembler/aopc2.c <<'@EOF' /* * Authors : * Pierre DAVID (pda@masi.ibp.fr or pda@frunip62.bitnet) * Janick TAILLANDIER * * This program can be freely used or distributed as long as this * note is kept. * * This program is provided "as is". */ /****************************************************************************** AREUH ASSEMBLER OPCODE PROCESSING (PART 2) ******************************************************************************/ #include "aglobal.h" #include "agen.h" extern void l_new_page(), l_print (), ps_line () ; extern int ascii_len () ; extern saddr calc_expression () ; int ltok = 255 ; /* lowest token */ int htok = 0 ; /* highest token */ int ctok = 0 ; /* current token */ int ckey = 0 ; /* current key macro-op */ /****************************************************************************** FILE_HEADER synopsis : file_header (modif, type) uchar *modif, *line description : expand a macro-op (LEX or BIN) ******************************************************************************/ file_header (modif, type) uchar *modif, *type ; { uchar line [MAXLEN+1], *pline, limit, c ; int i = 0, later = 0 ; uprc (modif) ; strcpy (line, " NIBASC ") ; pline = line + 9 ; limit = *modif ; if ((limit!='\'')&&(limit!='\\')) error (ERRIFL, "") ; /* inv. file name */ *pline = limit ; pline++ ; modif++ ; while ((i<=8)&&((c = *modif)!=limit)&&(c)) { i++ ; if (!( ((c>='A')&&(c<='Z')) || ((later)&&(c>='0')&&(c<='9')) ) ) error (ERRIFL, "") ; /* invalid file name */ later++ ; *pline = c ; modif++ ; pline++ ; } if ((i==0)||(i==9)) error (ERRIFL, "") ; while (i<8) { *pline = ' ' ; pline++ ; i++ ; } *pline = limit ; *(pline+1) = EOL ; ps_line (line) ; strcpy (line, " NIBHEX ") ; strcat (line, type) ; ps_line (line) ; ps_line (" CON(2) 0") ; /* copy code / secure code */ for (i=1; i<=5; i++) ps_line (" CON(2) #00") ; /* time */ ps_line (" REL(5) FiLeNd") ; ctok = ckey = 0 ; } /****************************************************************************** BSS synopsis : void bss (modif) char *modif description : areuh ******************************************************************************/ void bss (modif) uchar *modif ; { saddr val ; int i, m ; val = calc_expression (modif) ; if (val < 0L) error (ERRVMD, "BSS") ; /* fatal error */ gen_len = (int) val ; if (passnb==2) { m = (gen_len>18) ? 18 : gen_len ; for (i=0; ihtok) htok = tok ; break ; case 2 : if (cntlist) l_print (pc, gen_code, line, F_PC+F_LN+F_TL) ; sprintf (tmp, " CON(2) %s", modif) ; ps_line (tmp) ; print_this_line = gen_len = 0 ; break ; } /* du switch */ } void bin (modif, line) uchar *modif, *line ; { switch (passnb) { case 1 : if (linenb!=1) error (ERRLEX, "") ; /* invalid macro LEX or BIN */ modular = 0 ; gen_len = 37 ; break ; case 2 : if (cntlist) l_print (pc, gen_code, line, F_PC+F_LN+F_TL) ; file_header (modif, "402E") ; print_this_line = 0 ; gen_len = 0 ; break ; } } void chain (modif, line) uchar *modif, *line ; { uchar tmp [MAXLEN+1] ; switch (passnb) { case 1 : if (modular) error (ERRIMO, "CHAIN") ; break ; case 2 : if (cntlist) l_print (pc, gen_code, line, F_PC+F_LN+F_TL) ; if (calc_expression (modif) == EXP_ERR) ps_line (" CON(5) -1") ; else { sprintf (tmp, " REL(5) %s", modif) ; ps_line (tmp) ; } ps_line (" CON(5) -1") ; ps_line (" NIBHEX 20") ; print_this_line = gen_len = 0 ; break ; } } void endtxt (line) uchar *line ; { switch (passnb) { case 1 : if (modular) error (ERRIMO, "ENDTXT") ; if (!ckey) ps_line (" TxTbSt") ; /* if (!ckey) add_label (" TxTbSt", pc, "", LREL, 0) ; */ gen_len = 3 ; break ; case 2 : if (cntlist) l_print (pc, gen_code, line, F_PC+F_LN+F_TL) ; if (!ckey) ps_line (" TxTbSt") ; ps_line (" NIBHEX 1FF") ; print_this_line = gen_len = 0 ; break ; } /* du switch */ } void endifx () { if (!(in_if || in_else)) error (WRNIIF, "") ; /* Invalid conditional structure */ in_if = in_else = 0 ; exec = 1 ; } void absx (modif) /* FUTURE USE... */ uchar *modif ; { } void rdsymb (modif) uchar *modif ; { uchar *pmodif ; if (passnb==1) { pmodif = modif ; while ((*pmodif!=EOL)&&(*pmodif!='\t')&&(*pmodif!=' ')) pmodif++ ; *pmodif = EOL ; load_file (modif) ; } } void elsex () { if (!in_if) { error (WRNIIF, "") ; /* Invalid conditional structure */ in_if = in_else = 0 ; exec = 1 ; } else { in_if = 0 ; in_else = 1 ; exec = ! exec ; } } void ifx (modif) uchar *modif ; { saddr val ; if (in_if || in_else) { error (WRNIIF, "") ; /* Invalid conditional structure */ in_if = in_else = 0 ; exec = 1 ; } else { val = calc_expression (modif) ; if (val==EXP_EXT) error (WRNEXP, "") ; /* Illegal expression */ in_if = 1 ; in_else = 0 ; exec = (int) val ; } } @EOF set `wc -lwc areuh/assembler/apass.c <<'@EOF' /* * Authors : * Pierre DAVID (pda@masi.ibp.fr or pda@frunip62.bitnet) * Janick TAILLANDIER * * This program can be freely used or distributed as long as this * note is kept. * * This program is provided "as is". */ /****************************************************************************** AREUH ASSEMBLER PASS PROCESSING pass ******************************************************************************/ #include "aglobal.h" #include "agen.h" extern struct mnemo_desc *find_mnemo() ; extern int read_line(); extern void parse_line(), ps_label(), process_mnemo(), l_new_page(), l_print(), o_print() ; extern struct symbol *add_label() ; void ps_line() ; /****************************************************************************** PASS synopsis : void pass() description : ******************************************************************************/ void pass() { uchar line[MAXLEN+1]; int c; pc = 0 ; prev_test = 0 ; running = 1 ; exec = 1 ; in_if = in_else = 0 ; while (running) { c = read_line (fd_s, line) ; error_this_line = 0 ; if (c) running = 0 ; else ps_line (line) ; } if (passnb==1) { add_label("FiLeNd", pc, "", LREL, 0) ; } } /****************************************************************************** PS_LINE synopsis : void ps_line (line) uchar *line description : parses the line read from the input (breaks the line into three components), processes the label if necessary, processes the mnemonic if necessary, and does the listing and object file actualization, if pass one. ******************************************************************************/ void ps_line (line) uchar *line ; { uchar label[LBLLEN+2], mnemo[7], modif[MAXLEN+1] ; struct mnemo_desc *ad ; parse_line (line, label, mnemo, modif) ; if (!exec) { if ( (strcmp(mnemo, "IF"))&& (strcmp(mnemo, "ELSE"))&& (strcmp(mnemo, "ENDIF"))&& (strcmp(mnemo, "END")) ) return ; /* Neither IF nor ELSE nor ENDIF */ } if (*label) ps_label (label, mnemo, modif) ; *gen_code = EOL ; gen_len = 0 ; if (*mnemo) { ad = find_mnemo (mnemo) ; if (ad) { gen_len = ad->m_len ; switch (passnb) { case 1 : if (!((ad->m_flag)&F_LSET)) ps_mnemo (line, modif, ad) ; break ; case 2 : strcpy (gen_code, ad->m_code) ; ps_mnemo (line, modif, ad) ; if ((prev_test)&&(!(ad->m_flag & F_GOYS))) error (WRNYES, "") ; /* GOYES or RTNYES required */ break ; } } else { error (WRNOPC, "") ; /* unknown oopcode */ if (prev_test) error (WRNYES, "") ; /* GOYES or RTNYES required */ } } else ad = (struct mnemo_desc *) NULL ; if (passnb==2) { if ((cntlist)&&(print_this_line++)) l_print (pc, gen_code, line, F_PC+F_LN+F_GC+F_TL) ; o_print (gen_code, gen_len) ; if (ad) prev_test = ((ad->m_flag)&F_RETY) ? 1 : 0 ; } pc += gen_len ; } @EOF set `wc -lwc areuh/assembler/areport.c <<'@EOF' /* * Authors : * Pierre DAVID (pda@masi.ibp.fr or pda@frunip62.bitnet) * Janick TAILLANDIER * * This program can be freely used or distributed as long as this * note is kept. * * This program is provided "as is". */ /****************************************************************************** AREUH ASSEMBLER END OF ASSEMBLY REPORT print_ref, print_status, print_label, print_xref ******************************************************************************/ #include "aglobal.h" extern void l_print (), l_new_page () ; uchar format [15], formateq [16], xformat [MAXLEN], xf[15] ; void print_status (), print_label (), print_xref () ; /****************************************************************************** PRINT_REF synopsis : void print_ref () description : at the end of assembly (end of second pass), programmer want some informations on the program. This includes : - list of labels with their value, and cross reference - error count - time and date - that's all folks ******************************************************************************/ void print_ref () { sprintf (format, " %%-%ds %%s", LBLLEN) ; sprintf (formateq, "%%-%ds %%s", LBLLEN+1) ; sprintf (xf, "%%%ds+ ", LBLLEN+18) ; sprintf (xformat, xf, "") ; if ((cntlist) || (xref)) print_label() ; if (cntlist) print_status() ; else { if (errcnt) printf ("aas: %d errors in file %s\n", errcnt, fsource) ; } } /****************************************************************************** PRINT_STATUS synopsis : void print_status () description : reports some status lines after the assembly ******************************************************************************/ void print_status() { uchar line[MAXLEN+1], tmp[MAXLEN+1] ; l_print (0L, "", "", F_TL) ; l_print (0L, "", "", F_TL) ; l_print (0L, "", "", F_TL) ; l_print (0L, "", "", F_TL) ; l_print (0L, "", "", F_TL) ; l_print (0L, "", "", F_TL) ; sprintf (line, "Source : %s", fsource) ; l_print (0L, "", line, F_TL) ; l_print (0L, "", "", F_TL) ; sprintf (line, "Object : %s", fobject) ; l_print (0L, "", line, F_TL) ; l_print (0L, "", "", F_TL) ; strcpy (line, "Listing : ") ; if (cntlist == 1) strcat (line, "stdout") ; else strcat (line, flisting) ; l_print (0L, "", line, F_TL) ; l_print (0L, "", "", F_TL) ; format_time (tmp) ; sprintf (line, "Date : %s", tmp) ; l_print (0L, "", line, F_TL) ; l_print (0L, "", "", F_TL) ; sprintf (line, "Errors : %03d", errcnt) ; l_print (0L, "", line, F_TL) ; l_print (0L, "", "", F_TL) ; l_print (0L, "", "", F_TL) ; l_print (0L, "", "", F_TL) ; l_print (0L, "", "Areuh Assembler/Linker V2.4, (c) P. David & J. Taillandier 1986 Paris, France", F_TL) ; } /****************************************************************************** PRINT_LABEL synopsis : void print_label() description : prints a complete list of labels encoutered in the assembly. ******************************************************************************/ void print_label () { struct symbol *t ; struct xtable *x ; uchar line[MAXLEN+1], tmp[MAXLEN+1] ; int i ; strcpy (l_stitle, "**** SYMBOL TABLE ****") ; l_new_page (1) ; for (i=0; i<256; i++) { t = h_label[i]->s_next ; while (t) { if (!t->s_os) { if (t->s_value >= (saddr) 0) { hex5 (tmp, t->s_value) ; } else if (t->s_value == LBL_UDF) { strcpy (tmp, "Undef") ; } else if (t->s_value == LBL_EXT) { strcpy (tmp, "Extrn") ; } else /* (t->s_value == LBL_SEQ) || (t->s_value == LBL_XEQ) */ { strcpy (tmp, "Unkwn") ; } if (*(t->s_name)=='=') sprintf (line, formateq, t->s_name, tmp) ; else sprintf (line, format, t->s_name, tmp) ; if (xref) { switch (t->s_type) { case LUDF : strcat (line, " Ukn") ; break ; case LABS : strcat (line, " Abs") ; break ; case LREL : strcat (line, " Rel") ; break ; } if ((t->s_value!=LBL_UDF)&&(t->s_value!=LBL_EXT)) sprintf (tmp, "%s %04d - ", line, t->s_decl) ; else sprintf (tmp, "%s - ", line, t->s_decl) ; x = t->s_xref ; if (x) { while (x->x_next) x = x->x_next ; print_xref (x, tmp) ; } else { if (cntlist) l_print (0L, "", tmp, F_TL) ; else printf ("%s\n", tmp) ; } } else l_print (0L, "", line, F_TL) ; } /* if not (O.S. entry point not used) */ t = t->s_next ; } /* while */ } /* for */ } /****************************************************************************** PRINT_XREF synopsis : void print_xref (x, line) struct xtable *x uchar *line description : prints the complete cross-reference list backward from the end. x is the end of xref list, line is the line to be printed first. ******************************************************************************/ void print_xref (x, line) struct xtable *x ; uchar *line ; { int col = LBLLEN+21 ; /* column number */ uchar tmp[MAXLEN+1], strnum[MAXLEN+1] ; strcpy (tmp, line) ; while (x) { if (col>75) { if (cntlist) l_print (0L, "", tmp, F_TL) ; else printf ("%s\n", tmp) ; col = LBLLEN+21 ; strcpy (tmp, xformat) ; } sprintf (strnum, " %04d", x->x_line) ; strcat (tmp, strnum) ; col += 5 ; x = x->x_prev ; } if (cntlist) l_print (0L, "", tmp, F_TL) ; else printf ("%s\n", tmp) ; } @EOF set `wc -lwc areuh/assembler/autil.c <<'@EOF' /* * Authors : * Pierre DAVID (pda@masi.ibp.fr or pda@frunip62.bitnet) * Janick TAILLANDIER * * This program can be freely used or distributed as long as this * note is kept. * * This program is provided "as is". */ /****************************************************************************** TITAN ASSEMBLER GENERAL UTILITIES hard_init, soft_init, between, term, memoire ******************************************************************************/ #include "aglobal.h" void free_mem () ; extern void o_init() ; extern void dump_linker_infos () ; extern void l_init(), l_flush() ; extern void s_init() ; extern void i_tab0(), i_tab1(), i_tab2(), i_tab3(), i_tab4(), i_tab5() ; extern void print_ref() ; extern char *malloc () ; /****************************************************************************** INIT synopsis : void init() description : initiates the pass one. Opens source file, initializes the symbol list. Called for each file assembled. ******************************************************************************/ void init () { uchar file [MAXLEN+1], *psource, *pfile ; if (!try_source (fsource)) /* if can't open succesfully */ { pfile = file ; psource = fsource ; while ((*pfile = *psource) && (*pfile != '.')) { pfile++ ; psource++ ; } if (*pfile == EOL) { strcpy (pfile, ".as") ; if (try_source (file)) strcpy (fsource, file) ; } } if (fd_s==NULL) error (ERROPN, fsource) ; s_init() ; /* symbol table init */ passnb = 1 ; linenb = 0 ; cntlist = 0 ; modular = 1 ; *l_title = *l_stitle = EOL ; } /****************************************************************************** BETWEEN synopsis : void between() description : terminates the passe one, and prepares pass two. Restore file source pointer, opens object file. ******************************************************************************/ void between() { int r ; r = fseek (fd_s,0L,0); if (r) error (ERRREW, fsource) ; o_init() ; cntlist = cntlist_ref ; l_init() ; linenb = 0 ; passnb = 2 ; print_this_line = 1 ; errcnt = 0 ; headxu = (struct xused *) NULL ; } /****************************************************************************** TERM synopsis : void term () description : ends the pass two, and thus the assembly. Closes source file, and flushes object files. ******************************************************************************/ void term () { if (fclose (fd_s)) error (ERRCLO, fsource) ; if (modular) dump_linker_infos () ; if (fclose (fd_o)) error (ERRCLO, fobject) ; print_ref () ; l_flush () ; free_mem () ; } int try_source (file) uchar *file ; { long int magic ; fd_s = fopen (file, "r") ; if (fd_s) { fread (&magic, sizeof (long int), 1, fd_s) ; if (((magic>=ALF_MAGIC)&&(magic<=AL_MAGIC))|| ((magic>=AOF_MAGIC)&&(magic<=AO_MAGIC))) { fclose (fd_s) ; fd_s = (FILE *) NULL ; } else fseek (fd_s, 0L, 0) ; } return ((int) fd_s) ; } /****************************************************************************** MEMOIRE synopsis : uchar *memoire (size) int size description : get memory from heap using malloc. It is just a layer above malloc, including a test. ******************************************************************************/ uchar *memoire (size) int size ; { uchar *x ; if ((x = (uchar *) malloc (size)) == NULL) error (ERRMEM, "") ; return (x) ; } /****************************************************************************** UPRC synopsis : void uprc (str) uchar *str description : uppercase a string ******************************************************************************/ void uprc (str) uchar *str ; { while (*str) { if ((*str >= 'a') && (*str <= 'z')) *str -= 32 ; str++ ; } } /****************************************************************************** FORMAT_HEX synopsis : void format_hex (str, val, dig) uchar *str saddr val int dig description : stores into str the hexadecimal string representing the dig low order hex digits of val. ******************************************************************************/ void format_hex (str, val, dig) uchar *str ; saddr val ; int dig ; { register int i, h ; for (i=dig-1; i>=0; i--) { h = (int) (val & ((saddr) 0xf)) ; str [i] = h + ((h < 10) ? '0' : 'A' - 10) ; val >>= 4 ; } str [dig] = EOL ; } /****************************************************************************** FREE_MEM synopsis : void free_mem () description : frees all dynamically allocated memory during both passes. ******************************************************************************/ void free_mem () { struct xused *u ; struct symbol *s1, *s2 ; struct xtable *x1, *x2 ; int i ; for (i=0; i<=255; i++) { s1 = h_label[i]->s_next ; while (s1) { if (xref) { x1 = s1->s_xref ; while (x1) { x2 = x1->x_next ; free ((char *) x1) ; x1 = x2 ; } } if (s1->s_def) free ((char *) s1->s_def) ; s2 = s1->s_next ; free ((char *) s1) ; s1 = s2 ; } } free ((char *) h_label [0]) ; } @EOF set `wc -lwc areuh/assembler/common.h <<'@EOF' /* * Authors : * Pierre DAVID (pda@masi.ibp.fr or pda@frunip62.bitnet) * Janick TAILLANDIER * * This program can be freely used or distributed as long as this * note is kept. * * This program is provided "as is". */ #include #define MAXLEN 256 #define EOL '\0' #define LBLLEN 12 /****************************************************************************** TYPE DEFINITIONS ******************************************************************************/ typedef long int saddr ; /* Saturne address. At least 32 bits */ typedef unsigned char uchar ; /* unsigned characters, for accents */ typedef short int sint ; /* 16 bits */ /****************************************************************************** MAGIC NUMBERS ******************************************************************************/ #define AL_MAGIC 0x1b080100 /* ... areuh_lex */ #define AO_MAGIC 0x1b0d0100 /* ... areuh_output of assembler */ #define ALF_MAGIC 0x1b080100 /* first version of object file format */ #define AOF_MAGIC 0x1b0d0100 /* first version of object file format */ /****************************************************************************** USAGE TYPES IN .ao FILES ******************************************************************************/ #define XABSL 0x10 /* absolute reference */ #define XABSO 0x20 /* absolute reference, with one bias */ #define XRGTO 0x40 /* relative reference, goto type */ #define XRGSB 0x80 /* relative reference, gosub type */ /****************************************************************************** LABEL VALUES IN .ao FILES ******************************************************************************/ #define LBL_UDF -1L /* label not declared (implicit or explicit) <=> only used */ #define LBL_IVL -2L /* invalid label (invalid expression for an EQU during pass one) */ #define LBL_EXT -3L /* external label not defined here (or yet) */ #define LBL_XEQ -4L /* global label which is defined here, with an external reference */ #define LBL_SEQ -5L /* local label which is defined with an external reference */ /****************************************************************************** LABEL TYPES IN .ao FILES ******************************************************************************/ #define LUDF 0 /* undefined type (external label) */ #define LABS 1 /* absolute local label (declared explicitly, with constants) */ #define LREL 2 /* relative local label (declared implicitly, or explicitly with at least one relative) */ /****************************************************************************** VALUES RETURNED BY EXPRESSION EVALUATOR ******************************************************************************/ #define EXP_ERR -1L #define EXP_EXT -2L extern int relabs ; extern uchar extexp[] ; #include "err.h" extern void error () ; #define hex5(str,val) format_hex (str, val, 5) ; #define hex6(str,val) format_hex (str, val, 6) ; /****************************************************************************** MACHINE DEPENDANCIES ******************************************************************************/ #define HPUX 1 #define ATARI_LATTICE 0 #define PC_MSC 0 /* PC (beuark, Microsoft C) */ #if HPUX extern void format_time(), load_file() ; #define HP71EP "hp71.ep" #define RAO_MODE "r" #define WAO_MODE "w" #define skip(fp) #endif #if ATARI_LATTICE extern void format_time(), load_file() ; #define HP71EP "hp71.ep" #define RAO_MODE "rb" #define WAO_MODE "wb" extern char skipvar ; #define skip(fp) fread(&skipvar,1,1,fp) ; #endif #if PC_MSC extern void format_time(), load_file() ; #define HP71EP "hp71.ep" #define RAO_MODE "rb" #define WAO_MODE "wb" extern char skipvar ; #define skip(fp) fread(&skipvar,1,1,fp) ; #endif @EOF set `wc -lwc areuh/assembler/err.h <<'@EOF' /* * Authors : * Pierre DAVID (pda@masi.ibp.fr or pda@frunip62.bitnet) * Janick TAILLANDIER * * This program can be freely used or distributed as long as this * note is kept. * * This program is provided "as is". */ /****************************************************************************** AREUH ASSEMBLER / LINKER ERROR NUMBERS DECLARATIONS ******************************************************************************/ /* FATAL ERRORS */ #define ERROPN -1 /* A L */ /* system error opening file */ #define ERRCLO -2 /* A L */ /* system error closing file */ #define ERRREW -3 /* A */ /* system error on file at start of pass two */ #define ERRWRT -4 /* A L */ /* system error writing file */ #define ERRRD -5 /* A L */ /* system error reading file */ #define ERRMEM -6 /* A L */ /* not enough memory */ #define ERRLEX -10 /* A */ /* invalid macro pseudo-op LEX or BIN */ #define ERRPGS -11 /* A */ /* invalid page size */ #define ERRFLN -12 /* A */ /* restricted label FiLeNd exists */ #define ERRIFL -13 /* A L */ /* invalid file name */ #define ERRIMO -14 /* A */ /* invalid macro-op xx in modular assembling */ #define ERRVMD -15 /* A */ /* value must be defined for xx */ #define ERRUSA -20 /* A L */ /* usage: ass [ [-l] source_file ] */ /* usage: ald ... */ #define ERRNOA -30 /* L */ /* file not output from aas */ #define ERRICV -31 /* L */ /* incompatible version */ /* NON FATAL ERRORS */ #define WRNEQU 10 /* A */ /* cannot resolve equate */ #define WRNDUP 11 /* A L */ /* duplicate label */ #define WRNLBL 12 /* A */ /* illegal label */ #define WRNULB 13 /* A */ /* unrecognized label */ #define WRNURF 14 /* L */ /* unresolved reference */ #define WRNURL 15 /* L */ /* unresolved label */ #define WRNEXP 20 /* A */ /* illegal expression */ #define WRNASC 21 /* A */ /* illegal ascii constant */ #define WRNPAR 22 /* A */ /* mismatched parenthesis */ #define WRNIHX 23 /* A */ /* illegal hexadecimal constant */ #define WRNNUL 24 /* A */ /* null divisor */ #define WRNIXP 25 /* A */ /* illegal exponentiation */ #define WRNIBC 26 /* A */ /* illegal binary constant */ #define WRNENA 27 /* A */ /* external references not allowed */ #define WRNYES 30 /* A */ /* GOYES or RTNYES required */ #define WRNIDP 31 /* A */ /* illegal dp arithmetic value */ #define WRNIPP 32 /* A */ /* illegal pointer position */ #define WRNISB 33 /* A */ /* illegal status bit */ #define WRNTFR 34 /* A */ /* illegal transfer value */ #define WRNIWS 35 /* A */ /* illegal word select */ #define WRNLST 36 /* A */ /* invalid LIST argument */ #define WRNJVL 37 /* A L */ /* jump or value too large */ #define WRNMLB 38 /* A */ /* missing label */ #define WRNTST 39 /* A */ /* needs previous test instruction */ #define WRNNHX 40 /* A */ /* non hexadecimal digits present */ #define WRNTMA 41 /* A */ /* too many ascii characters present */ #define WRNTMH 42 /* A */ /* too many hexadecimal digits present */ #define WRNOPC 43 /* A */ /* unknown opcode */ #define WRNIIF 50 /* A */ /* invalid conditional structure */ extern void error() ; @EOF set `wc -lwc areuh/assembler/exp.c <<'@EOF' /* * Authors : * Pierre DAVID (pda@masi.ibp.fr or pda@frunip62.bitnet) * Janick TAILLANDIER * * This program can be freely used or distributed as long as this * note is kept. * * This program is provided "as is". */ /****************************************************************************** TITAN ASSEMBLER EXPRESSION EVALUATION calc_expression, reduce_E, reduce_T, reduce_F, reduce_B, reduce_X, reduce_P, dec_value, hex_value, bin_value, ascii_value, label_value, apply, trunc, next_char, append_extexp ******************************************************************************/ #include "flag.h" #if ASSEMBLER #include "aglobal.h" #else #include "lglobal.h" #endif uchar extexp [4*MAXLEN] ; uchar *pexp, *pextexp ; uchar *xlabel ; int relabs ; extern saddr symbol_value() ; saddr reduce_E(), reduce_T(), reduce_F(), reduce_B(), reduce_X(), reduce_P(), dec_value(), hex_value(), bin_value(), ascii_value(), label_value(), apply(), trunc() ; void next_char(), append_extexp() ; /****************************************************************************** CALC_EXPRESSION synopsis : saddr calc_expression (exp) uchar *exp description : That's the expression evaluator. Productions used are : E -> T { {+|-} T }* T -> F { {*|/} F }* F -> B { {&|!} B }* B -> X | -X | `X (two's and one's complement) X -> N { {~|^} N }* P -> D | # | % | '' | \\ |