fixed Constant Width
This commit is contained in:
parent
2db075ab69
commit
287f8d5d70
1 changed files with 52 additions and 36 deletions
|
@ -158,13 +158,15 @@ One of the most fundamental operations in EM is ``loc c'', load the value of c
|
||||||
on the stack. To expand this instruction the
|
on the stack. To expand this instruction the
|
||||||
tables contain the following information:
|
tables contain the following information:
|
||||||
.DS
|
.DS
|
||||||
EM_table : \fCW
|
EM_table :
|
||||||
|
.ft CW
|
||||||
C_loc ==> "pushl $$$1".
|
C_loc ==> "pushl $$$1".
|
||||||
/* $1 refers to the first argument of C_loc.
|
/* $1 refers to the first argument of C_loc.
|
||||||
* $$ is a quoted $. */
|
* $$ is a quoted $. */
|
||||||
|
|
||||||
|
|
||||||
\fRas_table :\fCW
|
\fRas_table :
|
||||||
|
.ft CW
|
||||||
pushl src : CONST ==>
|
pushl src : CONST ==>
|
||||||
@text1( 0xd0);
|
@text1( 0xd0);
|
||||||
@text1( 0xef);
|
@text1( 0xef);
|
||||||
|
@ -174,7 +176,7 @@ EM_table : \fCW
|
||||||
.LP
|
.LP
|
||||||
The as_table is transformed in the following routine:
|
The as_table is transformed in the following routine:
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
pushl_instr(src)
|
pushl_instr(src)
|
||||||
t_operand *src;
|
t_operand *src;
|
||||||
/* ``t_operand'' is a struct defined by the
|
/* ``t_operand'' is a struct defined by the
|
||||||
|
@ -189,7 +191,7 @@ t_operand *src;
|
||||||
.DE
|
.DE
|
||||||
Using ``pushl_instr()'', the following routine is generated from the EM_table:
|
Using ``pushl_instr()'', the following routine is generated from the EM_table:
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
C_loc( c)
|
C_loc( c)
|
||||||
arith c;
|
arith c;
|
||||||
/* text1() and text4() are library routines that fill the
|
/* text1() and text4() are library routines that fill the
|
||||||
|
@ -335,7 +337,7 @@ the speed of the actual code expander. Finally, actions can be grouped into
|
||||||
a list of actions; actions are separated by a semicolon and terminated
|
a list of actions; actions are separated by a semicolon and terminated
|
||||||
by a ``.''.
|
by a ``.''.
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
C_nop ==> .
|
C_nop ==> .
|
||||||
/* Empty action list : no operation. */
|
/* Empty action list : no operation. */
|
||||||
|
|
||||||
|
@ -362,7 +364,7 @@ action list.
|
||||||
.LP
|
.LP
|
||||||
The following example illustrates the usage of labels.
|
The following example illustrates the usage of labels.
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
/* Compare the two top elements on the stack. */
|
/* Compare the two top elements on the stack. */
|
||||||
C_cmp ==> "pop bx";
|
C_cmp ==> "pop bx";
|
||||||
"pop cx";
|
"pop cx";
|
||||||
|
@ -397,7 +399,7 @@ The value of the $\fIi\fR argument referring to a parameter ($\fIi\fR >= 0)
|
||||||
is increased by ``EM_BSIZE''. ``EM_BSIZE'' is the size of the return status block
|
is increased by ``EM_BSIZE''. ``EM_BSIZE'' is the size of the return status block
|
||||||
and must be defined in the file ``mach.h'' (see section 3.3). For example :
|
and must be defined in the file ``mach.h'' (see section 3.3). For example :
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
C_lol ==> "push $1(bp)".
|
C_lol ==> "push $1(bp)".
|
||||||
/* automatic conversion of $1 */
|
/* automatic conversion of $1 */
|
||||||
\fR
|
\fR
|
||||||
|
@ -409,7 +411,7 @@ transformed into a unique assembly name. To prevent name clashes with library
|
||||||
names the table writer has to provide the
|
names the table writer has to provide the
|
||||||
conversions in the file ``mach.h''. For example :
|
conversions in the file ``mach.h''. For example :
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
C_bra ==> "jmp $1".
|
C_bra ==> "jmp $1".
|
||||||
/* automatic conversion of $1 */
|
/* automatic conversion of $1 */
|
||||||
/* type arith is converted to string */
|
/* type arith is converted to string */
|
||||||
|
@ -435,7 +437,7 @@ The boolean expressions in a COND_SEQUENCE must be C expressions. Besides the
|
||||||
ordinary C operators and constants, $\fIi\fR references can be used
|
ordinary C operators and constants, $\fIi\fR references can be used
|
||||||
in an expression.
|
in an expression.
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
/* Load address of LB $1 levels back. */
|
/* Load address of LB $1 levels back. */
|
||||||
C_lxl
|
C_lxl
|
||||||
$1 == 0 ==> "pushl fp".
|
$1 == 0 ==> "pushl fp".
|
||||||
|
@ -454,7 +456,7 @@ these variants together. For this purpose the ``..'' notation is introduced.
|
||||||
For the code expander there is no difference between the
|
For the code expander there is no difference between the
|
||||||
following instructions.
|
following instructions.
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
C_loe_dlb ==> "pushl $1 + $2".
|
C_loe_dlb ==> "pushl $1 + $2".
|
||||||
C_loe_dnam ==> "pushl $1 + $2".
|
C_loe_dnam ==> "pushl $1 + $2".
|
||||||
C_loe ==> "pushl $1 + $2".
|
C_loe ==> "pushl $1 + $2".
|
||||||
|
@ -462,7 +464,7 @@ C_loe ==> "pushl $1 + $2".
|
||||||
.DE
|
.DE
|
||||||
So it can be written in the following way.
|
So it can be written in the following way.
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
C_loe.. ==> "pushl $1 + $2".
|
C_loe.. ==> "pushl $1 + $2".
|
||||||
\fR
|
\fR
|
||||||
.DE
|
.DE
|
||||||
|
@ -481,7 +483,7 @@ Most pseudo instructions are machine independent and are provided
|
||||||
by \fBceg\fR. The table writer has only to supply the following functions,
|
by \fBceg\fR. The table writer has only to supply the following functions,
|
||||||
which are used to build a stackframe:
|
which are used to build a stackframe:
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
C_prolog()
|
C_prolog()
|
||||||
/* Performs the prolog, for example save
|
/* Performs the prolog, for example save
|
||||||
* return address */
|
* return address */
|
||||||
|
@ -512,7 +514,7 @@ C_rom_icon, C_con_icon, C_bss_icon, C_hol_icon can be abbreviated by ..icon.
|
||||||
This also holds for ..ucon and ..fcon.
|
This also holds for ..ucon and ..fcon.
|
||||||
For example :
|
For example :
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
\\.\\.icon
|
\\.\\.icon
|
||||||
$2 == 1 ==> gen1( (ONE_BYTE) atoi( $1)).
|
$2 == 1 ==> gen1( (ONE_BYTE) atoi( $1)).
|
||||||
$2 == 2 ==> gen2( (TWO_BYTES) atoi( $1)).
|
$2 == 2 ==> gen2( (TWO_BYTES) atoi( $1)).
|
||||||
|
@ -630,7 +632,7 @@ There are three primitives that have to be defined by the table writer, either
|
||||||
as functions in the file ``mach.c'' or as rules in the EM_table.
|
as functions in the file ``mach.c'' or as rules in the EM_table.
|
||||||
For example, for the 8086 they look like this:
|
For example, for the 8086 they look like this:
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
C_jump ==> "jmp $1".
|
C_jump ==> "jmp $1".
|
||||||
|
|
||||||
C_prolog ==> "push bp";
|
C_prolog ==> "push bp";
|
||||||
|
@ -781,7 +783,7 @@ right hand side gives the corresponding actions as \fBback\fR-primitives or as
|
||||||
functions defined by the table writer, which call \fBback-primitives\fR.
|
functions defined by the table writer, which call \fBback-primitives\fR.
|
||||||
Two simple examples from the VAX as_table and the 8086 as_table, resp.:
|
Two simple examples from the VAX as_table and the 8086 as_table, resp.:
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
movl src, dst ==> @text1( 0xd0);
|
movl src, dst ==> @text1( 0xd0);
|
||||||
gen_operand( src);
|
gen_operand( src);
|
||||||
gen_operand( dst).
|
gen_operand( dst).
|
||||||
|
@ -822,7 +824,7 @@ that each mnemonic is mentioned only once in the as_table, otherwise
|
||||||
.PP
|
.PP
|
||||||
The following example shows the usage of type fields.
|
The following example shows the usage of type fields.
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
mov dst:REG, src:EADDR ==>
|
mov dst:REG, src:EADDR ==>
|
||||||
@text1( 0x8b); /* opcode */
|
@text1( 0x8b); /* opcode */
|
||||||
mod_RM( %d(dst->reg), src). /* operands */
|
mod_RM( %d(dst->reg), src). /* operands */
|
||||||
|
@ -832,8 +834,11 @@ The following example shows the usage of type fields.
|
||||||
mod_RM( %d(src->reg), dst). /* operands */
|
mod_RM( %d(src->reg), dst). /* operands */
|
||||||
\fR
|
\fR
|
||||||
.DE
|
.DE
|
||||||
The table-writer must supply the restriction functions, \fCWREG\fR and
|
The table-writer must supply the restriction functions,
|
||||||
\fCWEADDR\fR in the previous example, in ``as.c'' or ''as.h''.
|
.ft CW
|
||||||
|
REG\fR and
|
||||||
|
.ft CW
|
||||||
|
EADDR\fR in the previous example, in ``as.c'' or ''as.h''.
|
||||||
.NH 3
|
.NH 3
|
||||||
The function of the @-sign and the if-statement.
|
The function of the @-sign and the if-statement.
|
||||||
.PP
|
.PP
|
||||||
|
@ -842,7 +847,9 @@ Since the as_table is
|
||||||
interpreted on two levels, during code expander generation and during code
|
interpreted on two levels, during code expander generation and during code
|
||||||
expander execution, two levels of calls are present in it. A function-call
|
expander execution, two levels of calls are present in it. A function-call
|
||||||
without an ``@''-sign
|
without an ``@''-sign
|
||||||
is called during code expander generation (e.g., the \fCWgen_operand()\fR in the
|
is called during code expander generation (e.g., the
|
||||||
|
.ft CW
|
||||||
|
gen_operand()\fR in the
|
||||||
first example).
|
first example).
|
||||||
A function call with an ``@''-sign is called during code
|
A function call with an ``@''-sign is called during code
|
||||||
expander execution (e.g.,
|
expander execution (e.g.,
|
||||||
|
@ -854,7 +861,7 @@ can be replaced by ``move x, y'').
|
||||||
In this case flags need to be set, unset, and tested during the execution of
|
In this case flags need to be set, unset, and tested during the execution of
|
||||||
the compiler:
|
the compiler:
|
||||||
.DS L
|
.DS L
|
||||||
\fCW
|
.ft CW
|
||||||
PUSH src ==> /* save in ax */
|
PUSH src ==> /* save in ax */
|
||||||
mov_instr( AX_oper, src);
|
mov_instr( AX_oper, src);
|
||||||
/* set flag */
|
/* set flag */
|
||||||
|
@ -862,7 +869,7 @@ PUSH src ==> /* save in ax */
|
||||||
\fR
|
\fR
|
||||||
.DE
|
.DE
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
POP dst ==> @if ( push_waiting)
|
POP dst ==> @if ( push_waiting)
|
||||||
/* ``mov_instr'' is asg-generated */
|
/* ``mov_instr'' is asg-generated */
|
||||||
mov_instr( dst, AX_oper);
|
mov_instr( dst, AX_oper);
|
||||||
|
@ -889,7 +896,7 @@ run time of the \fBce\fR. In such a condition one may of course refer
|
||||||
to the ''$\fIi\fR'' arguments. For example, constants can be
|
to the ''$\fIi\fR'' arguments. For example, constants can be
|
||||||
packed into one or two byte arguments as follows:
|
packed into one or two byte arguments as follows:
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
mov dst:ACCU, src:DATA ==>
|
mov dst:ACCU, src:DATA ==>
|
||||||
@if ( fits_byte( %$(dst->expr)))
|
@if ( fits_byte( %$(dst->expr)))
|
||||||
@text1( 0xc0);
|
@text1( 0xc0);
|
||||||
|
@ -948,7 +955,7 @@ The following example illustrates the usage of ``%$''. (For an
|
||||||
example that illustrates the usage of ordinary fields see
|
example that illustrates the usage of ordinary fields see
|
||||||
the section on ``User supplied definitions and functions'').
|
the section on ``User supplied definitions and functions'').
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
jmp dst ==>
|
jmp dst ==>
|
||||||
@text1( 0xe9);
|
@text1( 0xe9);
|
||||||
@reloc2( %$(dst->lab), %$(dst->off), PC_REL).
|
@reloc2( %$(dst->lab), %$(dst->off), PC_REL).
|
||||||
|
@ -969,7 +976,7 @@ and reloc4()
|
||||||
calls, saving space and time (no relocation at compiler run time).
|
calls, saving space and time (no relocation at compiler run time).
|
||||||
The following example illustrates the usage of ``%dist''.
|
The following example illustrates the usage of ``%dist''.
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
jmp dst:ILB ==> /* label in an instruction list */
|
jmp dst:ILB ==> /* label in an instruction list */
|
||||||
@text1( 0xeb);
|
@text1( 0xeb);
|
||||||
@text1( %dist( dst->lab)).
|
@text1( %dist( dst->lab)).
|
||||||
|
@ -1012,7 +1019,7 @@ below).
|
||||||
If the default assemble() does not work the way the table writer wants, he
|
If the default assemble() does not work the way the table writer wants, he
|
||||||
can supply his own version of it. Assemble() has the following arguments:
|
can supply his own version of it. Assemble() has the following arguments:
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
assemble( instruction )
|
assemble( instruction )
|
||||||
char *instruction;
|
char *instruction;
|
||||||
\fR
|
\fR
|
||||||
|
@ -1027,7 +1034,7 @@ required on a block of assembly instructions, the table writer only has to
|
||||||
rewrite this function to get a new \fBceg\fR that obliges to his wishes.
|
rewrite this function to get a new \fBceg\fR that obliges to his wishes.
|
||||||
The function block_assemble has the following arguments:
|
The function block_assemble has the following arguments:
|
||||||
.DS
|
.DS
|
||||||
\fCW
|
.ft CW
|
||||||
block_assemble( instructions, nr, first, last)
|
block_assemble( instructions, nr, first, last)
|
||||||
char **instruction;
|
char **instruction;
|
||||||
int nr, first, last;
|
int nr, first, last;
|
||||||
|
@ -1053,7 +1060,7 @@ The following example shows the representative and essential parts of the
|
||||||
.nr VS 12
|
.nr VS 12
|
||||||
.LP
|
.LP
|
||||||
.DS L
|
.DS L
|
||||||
\fCW
|
.ft CW
|
||||||
/* Constants and type definitions in as.h */
|
/* Constants and type definitions in as.h */
|
||||||
|
|
||||||
#define UNKNOWN 0
|
#define UNKNOWN 0
|
||||||
|
@ -1101,7 +1108,7 @@ extern struct t_operand saved_op, *AX_oper;
|
||||||
.nr PS 10
|
.nr PS 10
|
||||||
.nr VS 12
|
.nr VS 12
|
||||||
.DS L
|
.DS L
|
||||||
\fCW
|
.ft CW
|
||||||
|
|
||||||
/* Some functions in as.c. */
|
/* Some functions in as.c. */
|
||||||
|
|
||||||
|
@ -1261,7 +1268,7 @@ for ``as_table'', ``as.h'', and ``as.c'' at this moment.
|
||||||
.IP \0\03:
|
.IP \0\03:
|
||||||
type
|
type
|
||||||
.br
|
.br
|
||||||
\fCW
|
.ft CW
|
||||||
install_ceg -as
|
install_ceg -as
|
||||||
\fR
|
\fR
|
||||||
.br
|
.br
|
||||||
|
@ -1272,7 +1279,9 @@ one for each
|
||||||
EM-instruction. All these files will be compiled and put in a library called
|
EM-instruction. All these files will be compiled and put in a library called
|
||||||
\fBce.a\fR.
|
\fBce.a\fR.
|
||||||
.br
|
.br
|
||||||
The option \fCW-as\fR means that a \fBback\fR-library will be
|
The option
|
||||||
|
.ft CW
|
||||||
|
-as\fR means that a \fBback\fR-library will be
|
||||||
generated (in the directory ``back'') that
|
generated (in the directory ``back'') that
|
||||||
supports the generation of assembly language. The library is named ``back.a''.
|
supports the generation of assembly language. The library is named ``back.a''.
|
||||||
.IP \0\04:
|
.IP \0\04:
|
||||||
|
@ -1284,7 +1293,7 @@ tested (e.g., by running the compiler on the EM test set). If an error occurs,
|
||||||
change the EM_table and type
|
change the EM_table and type
|
||||||
.IP
|
.IP
|
||||||
.br
|
.br
|
||||||
\fCW
|
.ft CW
|
||||||
update_ceg\fR \fBC_instr
|
update_ceg\fR \fBC_instr
|
||||||
\fR
|
\fR
|
||||||
.br
|
.br
|
||||||
|
@ -1305,13 +1314,18 @@ Write the ``as_table'', ``as.h'', and ``as.c'' files.
|
||||||
.IP \0\03:
|
.IP \0\03:
|
||||||
type
|
type
|
||||||
.sp
|
.sp
|
||||||
\fCW install_ceg -obj \fR
|
.ft CW
|
||||||
|
install_ceg -obj \fR
|
||||||
.sp
|
.sp
|
||||||
The option \fCW-obj\fR means that ``back.a'' will contain a library
|
The option
|
||||||
|
.ft CW
|
||||||
|
-obj\fR means that ``back.a'' will contain a library
|
||||||
for generating
|
for generating
|
||||||
ACK.OUT(5ACK) object files, see appendix B.
|
ACK.OUT(5ACK) object files, see appendix B.
|
||||||
If the writer does not want to use the default ``back.a'',
|
If the writer does not want to use the default ``back.a'',
|
||||||
the \fCW-obj\fR flag must omitted and a ``back.a'' should be supplied that
|
the
|
||||||
|
.ft CW
|
||||||
|
-obj\fR flag must omitted and a ``back.a'' should be supplied that
|
||||||
generates the generates object code in the desired format.
|
generates the generates object code in the desired format.
|
||||||
.IP \0\04:
|
.IP \0\04:
|
||||||
Link a front end, ``ce.a'', and ``back.a'' together resulting in a compiler
|
Link a front end, ``ce.a'', and ``back.a'' together resulting in a compiler
|
||||||
|
@ -1322,12 +1336,14 @@ Then there are two ways to proceed:
|
||||||
.IP \0\01:
|
.IP \0\01:
|
||||||
recompile the whole EM_table,
|
recompile the whole EM_table,
|
||||||
.sp
|
.sp
|
||||||
\fCW update_ceg ALL \fR
|
.ft CW
|
||||||
|
update_ceg ALL \fR
|
||||||
.sp
|
.sp
|
||||||
.IP \0\02:
|
.IP \0\02:
|
||||||
recompile just the few EM-instructions that contained the error,
|
recompile just the few EM-instructions that contained the error,
|
||||||
.sp
|
.sp
|
||||||
\fCW update_ceg \fBC_instr\fR
|
.ft CW
|
||||||
|
update_ceg \fBC_instr\fR
|
||||||
.sp
|
.sp
|
||||||
where \fBC_instr\fR is an erroneous EM-instruction.
|
where \fBC_instr\fR is an erroneous EM-instruction.
|
||||||
This has to be done for every EM-instruction that contained the erroneous
|
This has to be done for every EM-instruction that contained the erroneous
|
||||||
|
|
Loading…
Add table
Reference in a new issue