*** empty log message ***
authorkaashoek <none@none>
Thu, 26 Nov 1987 12:00:32 +0000 (12:00 +0000)
committerkaashoek <none@none>
Thu, 26 Nov 1987 12:00:32 +0000 (12:00 +0000)
util/ceg/assemble/obj_assemble/assemble.c
util/ceg/assemble/obj_assemble/block_as.c
util/ceg/assemble/obj_assemble/const.h

index 98ee719..eff6cf0 100644 (file)
@@ -3,14 +3,39 @@
 #include "as.h"
 #include "const.h"
 
+
+/* This file contains the routine assemble(). Assemble() cuts an
+ * assembly instruction in a label, a mnemonic and several operands.
+ * For a label and operands it calls table writer defined routines, 
+ * process_label() and process_operand(), to give the table writer 
+ * the oppurtunity to do something special. At the end assemble() calls
+ * the routine belonging to the mnemonic with the supplied operands.
+ *     If the table writer has other expectations of assemble() he should
+ * write his own version.
+ *     Assemble parser the following instructions :
+ * INSTR ::= [ STRING ':']? [ STRING [ OPERAND ( ',' OPERAND)*]? ]?
+ * OPERAND ::= STRING [ '{' char* '}' |
+ *                     '(' char* ')' | 
+ *                     '[' char* ']'     ]?
+ * note : nested brackets are not recognized.
+ */
+
+
+/* The following global varaibles are defined in the EM_parser.
+ */
+
 extern char *mnemonic[];
 extern int (*instruction[])(), n_mnems;
-struct t_operand operand[ MAX_OPERANDS];
 
-/* To change MAX_OPERANDS, the last statement in execute_mnem() must
- * be changed.
+/* The struct t_operand must be defined by the table writer in "as.h".
+ * The constant MAX_OPERANDS is defined in "const.h"
+ * To change MAX_OPERANDS effectively, the last statement in 
+ * execute_mnem() must be changed.
  */
 
+struct t_operand operand[ MAX_OPERANDS];
+
+
 
 char *skip_space(), *parse_label(), *parse_mnemonic(), *parse_operand(),
      *skip_string(), *match_ch(), *Salloc(), *skip_operand();
@@ -19,12 +44,7 @@ int  label();
 
 assemble( instr)
        char *instr;
-
-/* INSTR ::= [ STRING ':']? [ STRING [ OPERAND ( ',' OPERAND)*]? ]?
- * OPERAND ::= STRING [ '{' char* '}' |
- *                     '(' char* ')' | 
- *                     '[' char* ']'     ]?
- * Break an assembly instruction down in a LABEL, MNEMONIC and OPERANDS.
+/* Break an assembly instruction down in a LABEL, MNEMONIC and OPERANDS.
  */
 {
        char *ptr, *copy, *mnem;
@@ -33,19 +53,19 @@ assemble( instr)
        copy = ptr = Salloc( instr, strlen( instr)+1);
 
        ptr = skip_space( ptr);
-       if  ( label( ptr))  {
+       if  ( label( ptr))  {     /* Look for a label */
                ptr = parse_label( ptr);
                if  ( *ptr == '\0')  return;
        }
 
        ptr = parse_mnemonic( ptr, &mnem);
-       while  ( *ptr != '\0')  {
+       while  ( *ptr != '\0')  {  /* parse operans */
                if ( n_ops++ == MAX_OPERANDS) 
                        error( "to many operands\n");
                ptr = parse_operand( ptr, n_ops, instr);
        }
 
-       execute_mnemonic( mnem);
+       execute_mnemonic( mnem);   /* Execute the assembler instruction */
        free( copy);
 }
 
@@ -164,7 +184,7 @@ char *ptr;
 }
 
 
-/****************************************************************************/
+/*** Execution **************************************************************/
 
 
 execute_mnemonic( mnem)
@@ -198,13 +218,15 @@ char *mnem;
 }
 
 
+/*** Error ****************************************************************/
+
 error( fmt, argv)
 char *fmt;
 int argv;
 {
        extern int yylineno;
 
-       fprint( STDERR, "!! ERROR in line %d :  ", yylineno);
+       fprint( STDERR, "ERROR in line %d :     ", yylineno);
        doprnt( STDERR, fmt, &argv);
-       fprint( STDERR, "       !!\n");
+       fprint( STDERR, "\n");
 }
index 2b93b4d..d2d5a26 100644 (file)
@@ -1,4 +1,10 @@
 block_assemble( instructions, nr, first, last)
+
+/* Assembles a block of assembly instructions. If the table writer wants 
+ * to combine a block of instructions (e.g., push/pop optimization) he
+ * should changes this routine to his own needs.
+ */
+
 char **instructions;
 int nr, first, last;
 {
index e5acbcc..fc24538 100644 (file)
@@ -1,4 +1,3 @@
-
 #define Bool   int
 
 #define TRUE           1