several improvements

This commit is contained in:
ceriel 1990-02-05 10:06:42 +00:00
parent b40425786c
commit db54c35c24
17 changed files with 69 additions and 63 deletions

View file

@ -736,6 +736,7 @@ interchanged before being processed.
<num1> gives the number of lines of the first block. <num1> gives the number of lines of the first block.
<num2> gives the number of lines of the second one. <num2> gives the number of lines of the second one.
Blank and pure comment lines do not count. Blank and pure comment lines do not count.
This instruction is obsolete. Its use is strongly discouraged.
.OU .OU
.sp .sp
MES <num>,<val>* MES <num>,<val>*

View file

@ -154,7 +154,7 @@ mini with <num> as argument
mini with <num>*wordsize as argument mini with <num>*wordsize as argument
.PE 1 .PE 1
<num> is a possibly negative integer. <num> is a possibly negative integer.
.VS 1 1 .VS
.IE .IE
The dispatch table for the 256 primary opcodes: The dispatch table for the 256 primary opcodes:
.N 1 .N 1

View file

@ -141,7 +141,7 @@ have been added manually. Note that this code has already been optimized.
lol 0 lol 0
adp 2 adp 2
sti 8 ; r.r2 := sti 8 ; r.r2 :=
lni ; lin 23 prior to optimization lni ; lin 30 prior to optimization
lal \-224 lal \-224
lol \-4 lol \-4
lae .2 lae .2
@ -176,7 +176,7 @@ have been added manually. Note that this code has already been optimized.
sti 8 ; r2 := x + y sti 8 ; r2 := x + y
loc 0 loc 0
sil \-226 ; r1 := 0 sil \-226 ; r1 := 0
lin 34 ; note the abscence of the unnecesary jump lin 34 ; note the absence of the unnecessary jump
lae 22 ; address of output structure lae 22 ; address of output structure
lol \-4 lol \-4
cal $_wri ; write integer with default width cal $_wri ; write integer with default width

View file

@ -2,7 +2,10 @@
.AP "EM INTERPRETER" .AP "EM INTERPRETER"
.nf .nf
.ft CW .ft CW
.ta 8 16 24 32 40 48 56 64 72 80 .lg 0
.nr x \w' '
.ta \nxu +\nxu +\nxu +\nxu +\nxu +\nxu +\nxu +\nxu +\nxu +\nxu
.so em.i .so em.i
.ft P .ft P
.lg 1
.fi .fi

View file

@ -168,7 +168,7 @@ bit pattern:\fBddd\fP:\e\fBddd\fP
.TE .TE
.DE .DE
The escape \fB\eddd\fP consists of the backslash followed by 1, The escape \fB\eddd\fP consists of the backslash followed by 1,
2, or 3 octal digits specifing the value of 2, or 3 octal digits specifying the value of
the desired character. the desired character.
If the character following a backslash is not one of those If the character following a backslash is not one of those
specified, specified,
@ -206,11 +206,11 @@ l l l.
.TE .TE
.IE .IE
.S3 "Pseudoinstructions" .S3 "Pseudoinstructions"
.S4 Storage declaration .S4 "Storage declaration"
Initialized global data is allocated by the pseudoinstruction CON, Initialized global data is allocated by the pseudoinstruction CON,
which needs at least one argument. which needs at least one argument.
Each argument is used to allocate and initialize a number of Each argument is used to allocate and initialize a number of
consequtive bytes in data memory. consecutive bytes in data memory.
The number of bytes to be allocated and the alignment depend on the type The number of bytes to be allocated and the alignment depend on the type
of the argument. of the argument.
For each argument, an integral number of words, For each argument, an integral number of words,
@ -257,7 +257,7 @@ Switching to another type of fragment or placing a label forces
word-alignment. word-alignment.
There are three types of fragments in global data space: CON, ROM and There are three types of fragments in global data space: CON, ROM and
BSS/HOL. BSS/HOL.
.N 2 .N 1
.IS 2 .IS 2
.PS - 4 .PS - 4
.PT "BSS <cst1>,<val>,<cst2>" .PT "BSS <cst1>,<val>,<cst2>"
@ -277,7 +277,7 @@ Assemble global data words initialized with the <val> constants.
Idem, but the initialized data will never be changed by the program. Idem, but the initialized data will never be changed by the program.
.PE .PE
.IE .IE
.S4 Partitioning .S4 "Partitioning"
Two pseudoinstructions partition the input into procedures: Two pseudoinstructions partition the input into procedures:
.IS 2 .IS 2
.PS - 4 .PS - 4
@ -295,7 +295,7 @@ The number of bytes for locals must be specified in either the PRO or
END pseudoinstruction or both. END pseudoinstruction or both.
.PE .PE
.IE .IE
.S4 Visibility .S4 "Visibility"
Names of data and procedures in an EM module can either be Names of data and procedures in an EM module can either be
internal or external. internal or external.
External names are known outside the module and are used to link External names are known outside the module and are used to link
@ -329,7 +329,7 @@ Internal procedure.
<pro> is internal to this module and must be defined in this module. <pro> is internal to this module and must be defined in this module.
.PE .PE
.IE .IE
.S4 Miscellaneous .S4 "Miscellaneous"
Two other pseudoinstructions provide miscellaneous features: Two other pseudoinstructions provide miscellaneous features:
.IS 2 .IS 2
.PS - 4 .PS - 4
@ -339,6 +339,7 @@ interchanged before being processed.
<cst1> gives the number of lines of the first block. <cst1> gives the number of lines of the first block.
<cst2> gives the number of lines of the second one. <cst2> gives the number of lines of the second one.
Blank and pure comment lines do not count. Blank and pure comment lines do not count.
This instruction is obsolete. Its use is strongly discouraged.
.PT "MES <cst>[,<par>]*" .PT "MES <cst>[,<par>]*"
A special type of comment. A special type of comment.
Used by compilers to communicate with the Used by compilers to communicate with the
@ -400,7 +401,7 @@ the locals in this procedure should not be kept in registers and
all registers containing locals of other procedures should be all registers containing locals of other procedures should be
saved upon entry to this procedure. saved upon entry to this procedure.
.PE 1 .PE 1
.VS 1 1 .VS
Each backend is free to skip irrelevant MES pseudos. Each backend is free to skip irrelevant MES pseudos.
.PE .PE
.IE .IE
@ -456,6 +457,7 @@ r l.
Absence of an optional argument is indicated by a special Absence of an optional argument is indicated by a special
byte. byte.
.IE 2 .IE 2
.NE 7
.CS .CS
Common Table for Neutral State and Arguments Common Table for Neutral State and Arguments
.CE .CE
@ -490,7 +492,7 @@ are presented in two's complement notation, with the least
significant byte first. For example: the value of a 32 bit significant byte first. For example: the value of a 32 bit
constant is ((s4*256+b3)*256+b2)*256+b1, where s4 is b4\-256 if constant is ((s4*256+b3)*256+b2)*256+b1, where s4 is b4\-256 if
b4 is greater than 128 else s4 takes the value of b4. b4 is greater than 128 else s4 takes the value of b4.
A <string> consists of a <cst> inmediatly followed by A <string> consists of a <cst> immediately followed by
a sequence of bytes with length <cst>. a sequence of bytes with length <cst>.
.P .P
.ne 8 .ne 8
@ -588,6 +590,7 @@ Instructions that check for undefined integer or floating-point
values and underflow or overflow values and underflow or overflow
are indicated below by (*). are indicated below by (*).
.N 1 .N 1
.VS 0 0
.DS .DS
.ta 12n .ta 12n
GROUP 1 \- LOAD GROUP 1 \- LOAD
@ -799,3 +802,4 @@ GROUP 15 \- MISCELLANEOUS
STR \*r : Store register (0=LB, 1=SP, 2=HP) STR \*r : Store register (0=LB, 1=SP, 2=HP)
TRP \*- : Cause trap to occur (Error number on stack) TRP \*- : Cause trap to occur (Error number on stack)
.DE 0 .DE 0
.VS

View file

@ -18,9 +18,9 @@ Range check descriptors consist of two integers:
.IS 2 .IS 2
.PS 1 4 "" . .PS 1 4 "" .
.PT .PT
lower bound~~~~~~~signed lower bound signed
.PT .PT
upper bound~~~~~~~signed upper bound signed
.PE .PE
.IE .IE
The range check instruction checks an integer on the stack against The range check instruction checks an integer on the stack against
@ -34,11 +34,11 @@ Array descriptors contain the following three integers:
.IS 2 .IS 2
.PS 1 4 "" . .PS 1 4 "" .
.PT .PT
lower bound~~~~~~~~~~~~~~~~~~~~~signed lower bound signed
.PT .PT
upper bound \- lower bound~~~~~~~unsigned upper bound \- lower bound unsigned
.PT .PT
number of bytes per element~~~~~unsigned number of bytes per element unsigned
.PE .PE
.IE .IE
The array instructions LAR, SAR and AAR have the pointer to the start The array instructions LAR, SAR and AAR have the pointer to the start
@ -88,7 +88,7 @@ value of LB after the jump
.IE .IE
GTO replaces the loads PC, SP and LB from the descriptor, GTO replaces the loads PC, SP and LB from the descriptor,
thereby jumping to a procedure thereby jumping to a procedure
and removing zeor or more frames from the stack. and removing zero or more frames from the stack.
The LB, SP and PC in the descriptor must belong to a The LB, SP and PC in the descriptor must belong to a
dynamically enclosing procedure, dynamically enclosing procedure,
because some EM implementations will need to backtrack through because some EM implementations will need to backtrack through

View file

@ -70,7 +70,7 @@ The result of a LFR is only defined if the size used to fetch
is identical to the size used in the last return. is identical to the size used in the last return.
The instruction ASP, used to remove the parameters from the The instruction ASP, used to remove the parameters from the
stack, the branch instruction BRA and the non-local goto stack, the branch instruction BRA and the non-local goto
instrucion GTO are the only ones that leave the contents of instruction GTO are the only ones that leave the contents of
the 'function return area' intact. the 'function return area' intact.
All other instructions are allowed to destroy the function All other instructions are allowed to destroy the function
return area. return area.

View file

@ -159,7 +159,7 @@ var
iclass: insclass; { true for escaped opcodes } iclass: insclass; { true for escaped opcodes }
dispat: array[insclass,byte] of dispatch; dispat: array[insclass,byte] of dispatch;
retsize:size; { holds size of last LFR } retsize:size; { holds size of last LFR }
insr: mnem; { holds the instructionnumber } insr: mnem; { holds the instruction number }
halted: boolean; { normally false } halted: boolean; { normally false }
exitstatus:word; { parameter of MON 1 } exitstatus:word; { parameter of MON 1 }
ignmask:word; { ignore mask for traps } ignmask:word; { ignore mask for traps }
@ -522,7 +522,7 @@ begin j:=0;
end; end;
{---------------------------------------------------------------------------} {---------------------------------------------------------------------------}
{ Array indexing { Array indexing }
{---------------------------------------------------------------------------} {---------------------------------------------------------------------------}
function arraycalc(c:adr):adr; { subscript calculation } function arraycalc(c:adr):adr; { subscript calculation }

View file

@ -209,3 +209,4 @@ trap number \-3, the signal is ignored.
The flag returned by fork is 1 in the child process and 0 in The flag returned by fork is 1 in the child process and 0 in
the parent. the parent.
The pid returned is the process-id of the other process. The pid returned is the process-id of the other process.
.VS

View file

@ -86,7 +86,7 @@
lol 0 lol 0
adp 2 adp 2
sti 8 ; r.r2 := sti 8 ; r.r2 :=
lni ; was lin 23 prior to optimization lni ; was lin 30 prior to optimization
lal -224 lal -224
lol -4 lol -4
lae .2 lae .2
@ -121,7 +121,7 @@
sti 8 ; r2 := x + y sti 8 ; r2 := x + y
loc 0 loc 0
sil -226 ; r1 := 0 sil -226 ; r1 := 0
lin 34 ; note the abscence of the unnecesary jump lin 34 ; note the absence of the unnecessary jump
lae 22 ; address of output structure lae 22 ; address of output structure
lol -4 lol -4
cal $_wri ; write integer with default width cal $_wri ; write integer with default width

View file

@ -159,8 +159,11 @@ and not with the symbolic assembly language.
.P .P
As mentioned above, the As mentioned above, the
current microcomputer technology offers 8, 16 and 32 bit current microcomputer technology offers 8, 16 and 32 bit
machines with address spaces ranging from 2\v'-0.5m'16\v'0.5m' machines with address spaces ranging from
to 2\v'-0.5m'32\v'0.5m' bytes. .Ex 2 16
to
.Ex 2 32
bytes.
Having one size of pointers and integers restricts Having one size of pointers and integers restricts
the usefulness of the language. the usefulness of the language.
We decided to have a different language for each combination of We decided to have a different language for each combination of

View file

@ -22,19 +22,15 @@ two groups of 256 secondary opcodes each.
EM instructions without arguments have a single opcode assigned, EM instructions without arguments have a single opcode assigned,
possibly escaped: possibly escaped:
.Dr 6 .Dr 6
|--------------| |--------------|
| opcode | | opcode |
|--------------| |--------------|
.De .De
or or
.Dr 6 .Dr 6
|--------------|--------------| |--------------|--------------|
| escape | opcode | | escape | opcode |
|--------------|--------------| |--------------|--------------|
.De .De
The encoding for instructions with an argument is more complex. The encoding for instructions with an argument is more complex.
Several instructions have an address from the global data area Several instructions have an address from the global data area
@ -45,37 +41,29 @@ and negative arguments.
There is always an opcode that takes the next two bytes as argument, There is always an opcode that takes the next two bytes as argument,
high byte first: high byte first:
.Dr 6 .Dr 6
|--------------|--------------|--------------| |--------------|--------------|--------------|
| opcode | hibyte | lobyte | | opcode | hibyte | lobyte |
|--------------|--------------|--------------| |--------------|--------------|--------------|
.De .De
or or
.Dr 6 .Dr 6
|--------------|--------------|--------------|--------------| |--------------|--------------|--------------|--------------|
| escape | opcode | hibyte | lobyte | | escape | opcode | hibyte | lobyte |
|--------------|--------------|--------------|--------------| |--------------|--------------|--------------|--------------|
.De .De
An extra escape is provided for instructions with four or eight byte arguments. An extra escape is provided for instructions with four or eight byte arguments.
.Dr 6 .Dr 6
|--------------|--------------|--------------| |--------------|
|--------------|--------------|--------------| |--------------| | ESCAPE | opcode | hibyte |...| lobyte |
| ESCAPE | opcode | hibyte |...| lobyte | |--------------|--------------|--------------| |--------------|
|--------------|--------------|--------------| |--------------|
.De .De
For most instructions some argument values predominate. For most instructions some argument values predominate.
The most frequent combinations of instruction and argument The most frequent combinations of instruction and argument
will be encoded in a single byte, called a mini: will be encoded in a single byte, called a mini:
.Dr 6 .Dr 6
|---------------| |---------------|
|opcode+argument| (mini) |opcode+argument| (mini)
|---------------| |---------------|
.De .De
The number of minis is restricted, because only The number of minis is restricted, because only
254 primary opcodes are available. 254 primary opcodes are available.
@ -90,19 +78,15 @@ into a single opcode.
These opcodes are called shorties. These opcodes are called shorties.
Shorties may be escaped. Shorties may be escaped.
.Dr 6 .Dr 6
|--------------|--------------| |--------------|--------------|
| opcode+high | lobyte | (shortie) | opcode+high | lobyte | (shortie)
|--------------|--------------| |--------------|--------------|
.De .De
or or
.Dr 6 .Dr 6
|--------------|--------------|--------------| |--------------|--------------|--------------|
| escape | opcode+high | lobyte | | escape | opcode+high | lobyte |
|--------------|--------------|--------------| |--------------|--------------|--------------|
.De .De
Escaped shorties are useless if the normal encoding has a primary opcode. Escaped shorties are useless if the normal encoding has a primary opcode.
Note that for some instruction-argument combinations Note that for some instruction-argument combinations
@ -136,7 +120,7 @@ Each descriptor contains:
the number of bytes to be reserved for locals at each the number of bytes to be reserved for locals at each
invocation. invocation.
.N .N
This is a pointer-szied integer. This is a pointer-sized integer.
.PT 2. .PT 2.
the start address of the procedure the start address of the procedure
.PE .PE
@ -217,6 +201,7 @@ unused
unused unused
.PE .PE
.IE .IE
.VS
.P .P
The program text consists of NTEXT bytes. The program text consists of NTEXT bytes.
NTEXT is always a multiple of the wordsize. NTEXT is always a multiple of the wordsize.
@ -247,12 +232,12 @@ At load time an interpreter can
perform any conversion deemed necessary, such as perform any conversion deemed necessary, such as
reordering bytes in integers reordering bytes in integers
and pointers and adding base addresses to pointers. and pointers and adding base addresses to pointers.
.BP
.A .A
In the following pictures we show a graphical notation of the In the following pictures we show a graphical notation of the
initializers. initializers.
The leftmost rectangle represents the leading byte. The leftmost rectangle represents the leading byte.
.N 1 .N 1
.VS 1 0
.DS .DS
.PS - 4 " " .PS - 4 " "
Fields marked with Fields marked with
@ -271,9 +256,8 @@ contain a data or instruction pointer
contain a null terminated ASCII string contain a null terminated ASCII string
.PE 1 .PE 1
.DE 0 .DE 0
.VS 1 1 .VS
.Dr 6 .Dr 6
------------------- -------------------
| 0 | n | repeat last initialization n times | 0 | n | repeat last initialization n times
------------------- -------------------
@ -331,7 +315,7 @@ contain a null terminated ASCII string
------------------------- -------------------------
| 8 | m | s | initialized float of size m | 8 | m | s | initialized float of size m
------------------------- -------------------------
.De 3 .De
.PS - 8 .PS - 8
.PT type~0: .PT type~0:
If the last initialization initialized k bytes starting If the last initialization initialized k bytes starting

View file

@ -23,7 +23,7 @@
.. ..
.de Df \" Drawing Footer .de Df \" Drawing Footer
.N 1 .N 1
.FT P .ft R
.CS .CS
.lg 1 .lg 1
.. ..
@ -33,3 +33,7 @@
.AD .AD
.N \\$1 .N \\$1
.. ..
.\" macro for exponents, added by Ceriel Jacobs
.de Ex \" Exponent $1 $2 [$3]
\\$1\v'-0.5m'\s-2\\$2\s+2\v'0.5m'\\$3
..

View file

@ -195,7 +195,6 @@ LOI:1:pop:r0:pop:r0
LOE:40:push:eb+40:push:eb-41 LOE:40:push:eb+40:push:eb-41
.TE .TE
.DE .DE
.BP
.P .P
The translation for the two implementations, if the target machine address is The translation for the two implementations, if the target machine address is
used as pointer representation, is: used as pointer representation, is:

View file

@ -1,7 +1,8 @@
.po 0 .po 0
.TP 1 .TP 1
.ll 79n .ll 79n
.sp 15 \&
.sp 10
.ce 4 .ce 4
DESCRIPTION OF A MACHINE DESCRIPTION OF A MACHINE
ARCHITECTURE FOR USE WITH ARCHITECTURE FOR USE WITH

View file

@ -8,7 +8,7 @@ This mechanism uses five instructions: LIM, SIM, SIG, TRP and RTT.
This section of the manual may be omitted on the first reading since it This section of the manual may be omitted on the first reading since it
presupposes knowledge of the EM instruction set. presupposes knowledge of the EM instruction set.
.P .P
The action taken when a trap occures is determined by the value The action taken when a trap occurs is determined by the value
of an internal EM trap register. of an internal EM trap register.
This register contains a pointer to a procedure. This register contains a pointer to a procedure.
Initially the pointer used is zero and all traps halt the Initially the pointer used is zero and all traps halt the
@ -124,7 +124,7 @@ ersave
msave msave
bss 2,0,0 ; Room to save previous value of trap mask bss 2,0,0 ; Room to save previous value of trap mask
pro calcule,0 ; entry point pro $calcule,0 ; entry point
lxl 0 ; fill in non-local goto descriptor with LB lxl 0 ; fill in non-local goto descriptor with LB
ste jmpbuf+4 ste jmpbuf+4
lor 1 ; and SP lor 1 ; and SP
@ -151,11 +151,11 @@ jmpbuf
con *1,0,0 con *1,0,0
end end
.DE 0 .DE 0
.VS 1 1 .VS
.DS .DS
Example of catch procedure Example of catch procedure
.ta 1n 24n .ta 1n 24n
pro catch,0 ; Local procedure that must catch the overflow trap pro $catch,0 ; Local procedure that must catch the overflow trap
lol 2 ; Load trap number lol 2 ; Load trap number
loc 4 ; check for overflow loc 4 ; check for overflow
bne *1 ; if other trap, call higher trap procedure bne *1 ; if other trap, call higher trap procedure

View file

@ -33,7 +33,8 @@ restrictions imposed on the representation of the types used.
A number \fBn\fP used in these paragraphs indicates the size of A number \fBn\fP used in these paragraphs indicates the size of
the object in \fIbits\fP. the object in \fIbits\fP.
.S2 "Unsigned integers" .S2 "Unsigned integers"
The range of unsigned integers is 0..2\v'-0.5m'\fBn\fP\v'0.5m'\-1. The range of unsigned integers is 0..
.Ex 2 "\fBn\fP" -1.
A binary representation is assumed. A binary representation is assumed.
The order of the bits within an object is knowingly left The order of the bits within an object is knowingly left
unspecified. unspecified.
@ -61,17 +62,23 @@ We assume existence of at least single word unsigned arithmetic
in any implementation. in any implementation.
.S2 "Signed Integers" .S2 "Signed Integers"
The range of signed integers is The range of signed integers is
\-2\v'-0.5m'\fBn\fP\-1\v'0.5m'~..~2\v'-0.5m'\fBn\fP\-1\v'0.5m'\-1, .Ex \-2 "\fBn\fP\-1" ~..
.Ex 2 "\fBn\fP\-1" \-1,
in other words the range of signed integers of \fBn\fP bits in other words the range of signed integers of \fBn\fP bits
using two's complement arithmetic. using two's complement arithmetic.
The representation is the same as for unsigned integers except the range The representation is the same as for unsigned integers except the range
2\v'-0.5m'\fBn\fP\-1\v'0.5m'~..~2\v'-0.5m'\fBn\fP\v'0.5m'\-1 is mapped on the .Ex 2 "\fBn\fP\-1" ~..
range \-2\v'-0.5m'\fBn\fP\-1\v'0.5m'~..~\-1. .Ex 2 "\fBn\fP" \-1
is mapped on the
range
.Ex \-2 "\fBn\fP\-1" ~..~\-1.
In other words, the most significant bit is used as sign bit. In other words, the most significant bit is used as sign bit.
The convert instructions between signed and unsigned integers The convert instructions between signed and unsigned integers
of the same size can be used to catch errors. of the same size can be used to catch errors.
.A .A
The value \-2\v'-0.5m'\fBn\fP\-1\v'0.5m' is used for undefined The value
.Ex \-2 "\fBn\fP\-1"
is used for undefined
signed integers. signed integers.
EM implementations should trap when this value is used in an EM implementations should trap when this value is used in an
operation on signed integers. operation on signed integers.
@ -80,7 +87,6 @@ can be used to disable such traps.
.A .A
We assume existence of at least single word signed arithmetic We assume existence of at least single word signed arithmetic
in any implementation. in any implementation.
.BP
.S2 "Floating point values" .S2 "Floating point values"
Floating point values must have a signed mantissa and a signed Floating point values must have a signed mantissa and a signed
exponent. exponent.