*** empty log message ***

This commit is contained in:
kaashoek 1988-04-19 11:41:16 +00:00
parent 37a3f20b85
commit 805354f806

View file

@ -3,7 +3,7 @@
.nr LL 6i .nr LL 6i
.tr ~ .tr ~
.TL .TL
Code expander generator The Code Expander Generator
.AU .AU
Frans Kaashoek Frans Kaashoek
Koen Langendoen Koen Langendoen
@ -70,9 +70,9 @@ The code expander generator
.PP .PP
The code expander generator (\fBceg\fR) generates a code expander from The code expander generator (\fBceg\fR) generates a code expander from
two tables and a few machine-dependent functions. This section explains how two tables and a few machine-dependent functions. This section explains how
the \fBceg\fR works. The first half describes the transformations on the \fBceg\fR works. The first half describes the transformations that are done on
two tables. The second half tells how these transformations are done by the the two tables. The
\fBceg\fR. second half tells how these transformations are done by the \fBceg\fR.
.PP .PP
A code expander consists of a set of routines that convert EM-instructions A code expander consists of a set of routines that convert EM-instructions
directly to relocatable object code. These routines are called by a front directly to relocatable object code. These routines are called by a front
@ -84,13 +84,16 @@ interface. To free the table writer of the burden of building
an object file, we supply a set of routines that build an object file an object file, we supply a set of routines that build an object file
in the ACK_A.OUT(5L) in the ACK_A.OUT(5L)
.[~[ .[~[
ACK_A.OUT(5L) %T ACK_A.OUT(5L)
%J ACK Documentation
%I Vrije Universiteit
%C Amsterdam, The Netherlands
.]] .]]
format (see appendix B). This set of routines is called format (see appendix B). This set of routines is called
the the
\fBback\fR-primitives (see appendix A). In short, a code expander consists of a \fBback\fR-primitives (see appendix A). In short, a code expander consists of a
set of routines which map the EM_CODE interface on the set of routines which map the EM_CODE interface on the
\fBback\fR-primitives interface, which generate object code. \fBback\fR-primitives interface.
.PP .PP
To avoid repetition of the same sequences of To avoid repetition of the same sequences of
\fBback\fR-primitives in different \fBback\fR-primitives in different
@ -124,9 +127,9 @@ H: " back primitives" at F.end ljust
" (ACK_A.OUT)" at H - (0, 0.2i) ljust " (ACK_A.OUT)" at H - (0, 0.2i) ljust
.PE .PE
.PP .PP
Although the picture suggests that during compilation of the EM instructions are Although the picture suggests that during compilation the EM instructions are
first transformed into assembly instructions and then the assembly instructions first transformed into assembly instructions and then the assembly instructions
are transformed into object-generating calls, the \fBback-primitives\fR, this are transformed into object-generating calls, this
is not what happens in practice, although the user is free to think it does. is not what happens in practice, although the user is free to think it does.
Actually, however the EM_table and the as_table are combined during code Actually, however the EM_table and the as_table are combined during code
expander generation time, yielding an imaginary compound table that results in expander generation time, yielding an imaginary compound table that results in
@ -134,15 +137,18 @@ routines from the EM_CODE interface that generate object code directly.
.PP .PP
As already indicated, the compound table does not exist either. Instead, each As already indicated, the compound table does not exist either. Instead, each
assembly instruction in the as_table is converted to a routine generating C assembly instruction in the as_table is converted to a routine generating C
code
.[~[ .[~[
Kernighan Kernighan
.]] .]]
code to generate C code to call the \fBback\fR-primitives. The EM_table is to generate C code to call the \fBback\fR-primitives. The EM_table is
converted into a program that for each EM instruction generates a routine, converted into a program that for each EM instruction generates a routine,
using the routines generated from the as_table. Execution of the latter program using the routines generated from the as_table. Execution of the latter program
will then generate the code expander. will then generate the code expander.
.PP .PP
This scheme allows great flexibility in the table writing, while still This scheme allows great flexibility (e.g., when \fBceg\fR is called with a
special flag it generates assembly instead of object code)
in the table writing, while still
resulting in a very efficient code expander. One implication is that the resulting in a very efficient code expander. One implication is that the
as_table is interpreted twice and the EM_table only once. This has consequences as_table is interpreted twice and the EM_table only once. This has consequences
for their structure. for their structure.
@ -197,7 +203,7 @@ arith c;
\fR \fR
.DE .DE
.LP .LP
A compiler call to "C_loc" will cause the 1-byte numbers "0xd0" A compiler call to "C_loc()" will cause the 1-byte numbers "0xd0"
and "0xef" and "0xef"
and the 4-byte value of the variable "c" to be stored in the text segment. and the 4-byte value of the variable "c" to be stored in the text segment.
.PP .PP
@ -271,14 +277,13 @@ SIMPLE%::=%( "==>" | "::=") ACTION_LIST
ACTION_LIST%::=%[ ACTION ( ";" ACTION)* ] "." ACTION_LIST%::=%[ ACTION ( ";" ACTION)* ] "."
ACTION%::=%AS_INSTR ACTION%::=%AS_INSTR
%|%function-call %|%function-call
.sp
AS_INSTR%::=%""" [ label ":"] [ INSTR] """ AS_INSTR%::=%""" [ label ":"] [ INSTR] """
INSTR%::=%mnemonic [ operand ( "," operand)* ] INSTR%::=%mnemonic [ operand ( "," operand)* ]
.TE .TE
.VS -4 .VS -4
.PP .PP
\"(" ")" brackets are used for grouping, "[" ... "]" means ... 0 or 1 time, The "(" ")" brackets are used for grouping, "[" ... "]" means ... 0 or 1 time,
\"*" means zero or more times, "+" means one or more times and "|" means a "*" means zero or more times, a "+" means one or more times and a "|" means
a choice between left or right. A \fBC_instr\fR is a choice between left or right. A \fBC_instr\fR is
a name in the EM_CODE(3ACK) interface. \fBcondition\fR is a C expression. a name in the EM_CODE(3ACK) interface. \fBcondition\fR is a C expression.
\fBfunction-call\fR is a call of a C function. \fBlabel\fR, \fBmnemonic\fR \fBfunction-call\fR is a call of a C function. \fBlabel\fR, \fBmnemonic\fR
@ -550,7 +555,7 @@ must contain %s.
T} T}
DLB_FMT#:#T{ DLB_FMT#:#T{
Print format describing numerical-data-label to a unique name conversion. Print format describing numerical-data-label to a unique name conversion.
The format must contain a %d. The format must contain a %ld.
T} T}
ILB_FMT#:#T{ ILB_FMT#:#T{
Print format describing instruction-label to a unique name conversion. Print format describing instruction-label to a unique name conversion.
@ -589,7 +594,7 @@ BYTES_REVERSED#:#T{
Must be defined if you want the byte order reversed. Must be defined if you want the byte order reversed.
By default the least significant byte is outputted first. By default the least significant byte is outputted first.
.FS .FS
When both byte orders occur, for example NS 16032, the table writer has to When both byte orders are used, for example NS 16032, the table writer has to
supply his own set of routines. supply his own set of routines.
.FE .FE
T} T}
@ -645,7 +650,7 @@ Generating assembly code
When the code expander generator is used for generating assembly instead of When the code expander generator is used for generating assembly instead of
object code, not all the above mentioned constants and functions have to object code, not all the above mentioned constants and functions have to
be defined. In this case, the constants "BYTES_REVERSED" and "WORDS_REVERSED" be defined. In this case, the constants "BYTES_REVERSED" and "WORDS_REVERSED"
are not used. are not used (see section 5).
.NH 1 .NH 1
Description of the as_table Description of the as_table
.PP .PP
@ -843,6 +848,9 @@ the type of the operand in the following way.
"$" | "$" |
"dist" "dist"
printformat := see PRINT(3ACK) printformat := see PRINT(3ACK)
.[~[
PRINT
.]]
\fR \fR
.DE .DE
The three cases differ only in the conversion field. The first conversion The three cases differ only in the conversion field. The first conversion
@ -930,12 +938,16 @@ contains function calls other than the \fBback\fR-primitives, these functions
must also be present in "as.c". Note that both the "@"-sign (see 4.2.3) must also be present in "as.c". Note that both the "@"-sign (see 4.2.3)
and "references" and "references"
(see 4.2.4) also work in (see 4.2.4) also work in
the functions defined in "as.c". Example, part of 8086 "as.h" and "as.c" the functions defined in "as.c".
files : .sp
The folowing example shows a part of 8086 "as.h" and "as.c" files:
.nr PS 10 .nr PS 10
.nr VS 12 .nr VS 12
.DS L .DS L
\f5 \f5
/* Constants and type definitions in as.h */
#define UNKNOWN 0 #define UNKNOWN 0
#define IS_REG 0x1 #define IS_REG 0x1
#define IS_ACCU 0x2 #define IS_ACCU 0x2
@ -977,6 +989,9 @@ extern struct t_operand saved_op, *AX_oper;
.DE .DE
.DS L .DS L
\f5 \f5
/* Some functions in as.c. */
#include "arg_type.h" #include "arg_type.h"
#include "as.h" #include "as.h"
@ -1037,6 +1052,7 @@ struct t_operand *op;
} }
} }
/*********************************************************************/
mod_RM( reg, op) mod_RM( reg, op)
int reg; int reg;