several improvements
This commit is contained in:
parent
b40425786c
commit
db54c35c24
|
@ -736,6 +736,7 @@ interchanged before being processed.
|
|||
<num1> gives the number of lines of the first block.
|
||||
<num2> gives the number of lines of the second one.
|
||||
Blank and pure comment lines do not count.
|
||||
This instruction is obsolete. Its use is strongly discouraged.
|
||||
.OU
|
||||
.sp
|
||||
MES <num>,<val>*
|
||||
|
|
|
@ -154,7 +154,7 @@ mini with <num> as argument
|
|||
mini with <num>*wordsize as argument
|
||||
.PE 1
|
||||
<num> is a possibly negative integer.
|
||||
.VS 1 1
|
||||
.VS
|
||||
.IE
|
||||
The dispatch table for the 256 primary opcodes:
|
||||
.N 1
|
||||
|
|
|
@ -141,7 +141,7 @@ have been added manually. Note that this code has already been optimized.
|
|||
lol 0
|
||||
adp 2
|
||||
sti 8 ; r.r2 :=
|
||||
lni ; lin 23 prior to optimization
|
||||
lni ; lin 30 prior to optimization
|
||||
lal \-224
|
||||
lol \-4
|
||||
lae .2
|
||||
|
@ -176,7 +176,7 @@ have been added manually. Note that this code has already been optimized.
|
|||
sti 8 ; r2 := x + y
|
||||
loc 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
|
||||
lol \-4
|
||||
cal $_wri ; write integer with default width
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
.AP "EM INTERPRETER"
|
||||
.nf
|
||||
.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
|
||||
.ft P
|
||||
.lg 1
|
||||
.fi
|
||||
|
|
|
@ -168,7 +168,7 @@ bit pattern:\fBddd\fP:\e\fBddd\fP
|
|||
.TE
|
||||
.DE
|
||||
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.
|
||||
If the character following a backslash is not one of those
|
||||
specified,
|
||||
|
@ -206,11 +206,11 @@ l l l.
|
|||
.TE
|
||||
.IE
|
||||
.S3 "Pseudoinstructions"
|
||||
.S4 Storage declaration
|
||||
.S4 "Storage declaration"
|
||||
Initialized global data is allocated by the pseudoinstruction CON,
|
||||
which needs at least one argument.
|
||||
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
|
||||
of the argument.
|
||||
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.
|
||||
There are three types of fragments in global data space: CON, ROM and
|
||||
BSS/HOL.
|
||||
.N 2
|
||||
.N 1
|
||||
.IS 2
|
||||
.PS - 4
|
||||
.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.
|
||||
.PE
|
||||
.IE
|
||||
.S4 Partitioning
|
||||
.S4 "Partitioning"
|
||||
Two pseudoinstructions partition the input into procedures:
|
||||
.IS 2
|
||||
.PS - 4
|
||||
|
@ -295,7 +295,7 @@ The number of bytes for locals must be specified in either the PRO or
|
|||
END pseudoinstruction or both.
|
||||
.PE
|
||||
.IE
|
||||
.S4 Visibility
|
||||
.S4 "Visibility"
|
||||
Names of data and procedures in an EM module can either be
|
||||
internal or external.
|
||||
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.
|
||||
.PE
|
||||
.IE
|
||||
.S4 Miscellaneous
|
||||
.S4 "Miscellaneous"
|
||||
Two other pseudoinstructions provide miscellaneous features:
|
||||
.IS 2
|
||||
.PS - 4
|
||||
|
@ -339,6 +339,7 @@ interchanged before being processed.
|
|||
<cst1> gives the number of lines of the first block.
|
||||
<cst2> gives the number of lines of the second one.
|
||||
Blank and pure comment lines do not count.
|
||||
This instruction is obsolete. Its use is strongly discouraged.
|
||||
.PT "MES <cst>[,<par>]*"
|
||||
A special type of comment.
|
||||
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
|
||||
saved upon entry to this procedure.
|
||||
.PE 1
|
||||
.VS 1 1
|
||||
.VS
|
||||
Each backend is free to skip irrelevant MES pseudos.
|
||||
.PE
|
||||
.IE
|
||||
|
@ -456,6 +457,7 @@ r l.
|
|||
Absence of an optional argument is indicated by a special
|
||||
byte.
|
||||
.IE 2
|
||||
.NE 7
|
||||
.CS
|
||||
Common Table for Neutral State and Arguments
|
||||
.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
|
||||
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.
|
||||
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>.
|
||||
.P
|
||||
.ne 8
|
||||
|
@ -588,6 +590,7 @@ Instructions that check for undefined integer or floating-point
|
|||
values and underflow or overflow
|
||||
are indicated below by (*).
|
||||
.N 1
|
||||
.VS 0 0
|
||||
.DS
|
||||
.ta 12n
|
||||
GROUP 1 \- LOAD
|
||||
|
@ -799,3 +802,4 @@ GROUP 15 \- MISCELLANEOUS
|
|||
STR \*r : Store register (0=LB, 1=SP, 2=HP)
|
||||
TRP \*- : Cause trap to occur (Error number on stack)
|
||||
.DE 0
|
||||
.VS
|
||||
|
|
|
@ -18,9 +18,9 @@ Range check descriptors consist of two integers:
|
|||
.IS 2
|
||||
.PS 1 4 "" .
|
||||
.PT
|
||||
lower bound~~~~~~~signed
|
||||
lower bound signed
|
||||
.PT
|
||||
upper bound~~~~~~~signed
|
||||
upper bound signed
|
||||
.PE
|
||||
.IE
|
||||
The range check instruction checks an integer on the stack against
|
||||
|
@ -34,11 +34,11 @@ Array descriptors contain the following three integers:
|
|||
.IS 2
|
||||
.PS 1 4 "" .
|
||||
.PT
|
||||
lower bound~~~~~~~~~~~~~~~~~~~~~signed
|
||||
lower bound signed
|
||||
.PT
|
||||
upper bound \- lower bound~~~~~~~unsigned
|
||||
upper bound \- lower bound unsigned
|
||||
.PT
|
||||
number of bytes per element~~~~~unsigned
|
||||
number of bytes per element unsigned
|
||||
.PE
|
||||
.IE
|
||||
The array instructions LAR, SAR and AAR have the pointer to the start
|
||||
|
@ -88,7 +88,7 @@ value of LB after the jump
|
|||
.IE
|
||||
GTO replaces the loads PC, SP and LB from the descriptor,
|
||||
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
|
||||
dynamically enclosing procedure,
|
||||
because some EM implementations will need to backtrack through
|
||||
|
|
|
@ -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.
|
||||
The instruction ASP, used to remove the parameters from the
|
||||
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.
|
||||
All other instructions are allowed to destroy the function
|
||||
return area.
|
||||
|
|
|
@ -159,7 +159,7 @@ var
|
|||
iclass: insclass; { true for escaped opcodes }
|
||||
dispat: array[insclass,byte] of dispatch;
|
||||
retsize:size; { holds size of last LFR }
|
||||
insr: mnem; { holds the instructionnumber }
|
||||
insr: mnem; { holds the instruction number }
|
||||
halted: boolean; { normally false }
|
||||
exitstatus:word; { parameter of MON 1 }
|
||||
ignmask:word; { ignore mask for traps }
|
||||
|
@ -522,7 +522,7 @@ begin j:=0;
|
|||
end;
|
||||
|
||||
{---------------------------------------------------------------------------}
|
||||
{ Array indexing
|
||||
{ Array indexing }
|
||||
{---------------------------------------------------------------------------}
|
||||
|
||||
function arraycalc(c:adr):adr; { subscript calculation }
|
||||
|
|
|
@ -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 parent.
|
||||
The pid returned is the process-id of the other process.
|
||||
.VS
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
lol 0
|
||||
adp 2
|
||||
sti 8 ; r.r2 :=
|
||||
lni ; was lin 23 prior to optimization
|
||||
lni ; was lin 30 prior to optimization
|
||||
lal -224
|
||||
lol -4
|
||||
lae .2
|
||||
|
@ -121,7 +121,7 @@
|
|||
sti 8 ; r2 := x + y
|
||||
loc 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
|
||||
lol -4
|
||||
cal $_wri ; write integer with default width
|
||||
|
|
|
@ -159,8 +159,11 @@ and not with the symbolic assembly language.
|
|||
.P
|
||||
As mentioned above, the
|
||||
current microcomputer technology offers 8, 16 and 32 bit
|
||||
machines with address spaces ranging from 2\v'-0.5m'16\v'0.5m'
|
||||
to 2\v'-0.5m'32\v'0.5m' bytes.
|
||||
machines with address spaces ranging from
|
||||
.Ex 2 16
|
||||
to
|
||||
.Ex 2 32
|
||||
bytes.
|
||||
Having one size of pointers and integers restricts
|
||||
the usefulness of the language.
|
||||
We decided to have a different language for each combination of
|
||||
|
|
|
@ -22,19 +22,15 @@ two groups of 256 secondary opcodes each.
|
|||
EM instructions without arguments have a single opcode assigned,
|
||||
possibly escaped:
|
||||
.Dr 6
|
||||
|
||||
|--------------|
|
||||
| opcode |
|
||||
|--------------|
|
||||
|
||||
.De
|
||||
or
|
||||
.Dr 6
|
||||
|
||||
|--------------|--------------|
|
||||
| escape | opcode |
|
||||
|--------------|--------------|
|
||||
|
||||
.De
|
||||
The encoding for instructions with an argument is more complex.
|
||||
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,
|
||||
high byte first:
|
||||
.Dr 6
|
||||
|
||||
|--------------|--------------|--------------|
|
||||
| opcode | hibyte | lobyte |
|
||||
|--------------|--------------|--------------|
|
||||
|
||||
.De
|
||||
or
|
||||
.Dr 6
|
||||
|
||||
|--------------|--------------|--------------|--------------|
|
||||
| escape | opcode | hibyte | lobyte |
|
||||
|--------------|--------------|--------------|--------------|
|
||||
|
||||
.De
|
||||
An extra escape is provided for instructions with four or eight byte arguments.
|
||||
.Dr 6
|
||||
|
||||
|--------------|--------------|--------------| |--------------|
|
||||
| ESCAPE | opcode | hibyte |...| lobyte |
|
||||
|--------------|--------------|--------------| |--------------|
|
||||
|
||||
|--------------|--------------|--------------| |--------------|
|
||||
| ESCAPE | opcode | hibyte |...| lobyte |
|
||||
|--------------|--------------|--------------| |--------------|
|
||||
.De
|
||||
For most instructions some argument values predominate.
|
||||
The most frequent combinations of instruction and argument
|
||||
will be encoded in a single byte, called a mini:
|
||||
.Dr 6
|
||||
|
||||
|---------------|
|
||||
|opcode+argument| (mini)
|
||||
|---------------|
|
||||
|
||||
.De
|
||||
The number of minis is restricted, because only
|
||||
254 primary opcodes are available.
|
||||
|
@ -90,19 +78,15 @@ into a single opcode.
|
|||
These opcodes are called shorties.
|
||||
Shorties may be escaped.
|
||||
.Dr 6
|
||||
|
||||
|--------------|--------------|
|
||||
| opcode+high | lobyte | (shortie)
|
||||
|--------------|--------------|
|
||||
|
||||
.De
|
||||
or
|
||||
.Dr 6
|
||||
|
||||
|--------------|--------------|--------------|
|
||||
| escape | opcode+high | lobyte |
|
||||
|--------------|--------------|--------------|
|
||||
|
||||
.De
|
||||
Escaped shorties are useless if the normal encoding has a primary opcode.
|
||||
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
|
||||
invocation.
|
||||
.N
|
||||
This is a pointer-szied integer.
|
||||
This is a pointer-sized integer.
|
||||
.PT 2.
|
||||
the start address of the procedure
|
||||
.PE
|
||||
|
@ -217,6 +201,7 @@ unused
|
|||
unused
|
||||
.PE
|
||||
.IE
|
||||
.VS
|
||||
.P
|
||||
The program text consists of NTEXT bytes.
|
||||
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
|
||||
reordering bytes in integers
|
||||
and pointers and adding base addresses to pointers.
|
||||
.BP
|
||||
.A
|
||||
In the following pictures we show a graphical notation of the
|
||||
initializers.
|
||||
The leftmost rectangle represents the leading byte.
|
||||
.N 1
|
||||
.VS 1 0
|
||||
.DS
|
||||
.PS - 4 " "
|
||||
Fields marked with
|
||||
|
@ -271,9 +256,8 @@ contain a data or instruction pointer
|
|||
contain a null terminated ASCII string
|
||||
.PE 1
|
||||
.DE 0
|
||||
.VS 1 1
|
||||
.VS
|
||||
.Dr 6
|
||||
|
||||
-------------------
|
||||
| 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
|
||||
-------------------------
|
||||
.De 3
|
||||
.De
|
||||
.PS - 8
|
||||
.PT type~0:
|
||||
If the last initialization initialized k bytes starting
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
..
|
||||
.de Df \" Drawing Footer
|
||||
.N 1
|
||||
.FT P
|
||||
.ft R
|
||||
.CS
|
||||
.lg 1
|
||||
..
|
||||
|
@ -33,3 +33,7 @@
|
|||
.AD
|
||||
.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
|
||||
..
|
||||
|
|
|
@ -195,7 +195,6 @@ LOI:1:pop:r0:pop:r0
|
|||
LOE:40:push:eb+40:push:eb-41
|
||||
.TE
|
||||
.DE
|
||||
.BP
|
||||
.P
|
||||
The translation for the two implementations, if the target machine address is
|
||||
used as pointer representation, is:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
.po 0
|
||||
.TP 1
|
||||
.ll 79n
|
||||
.sp 15
|
||||
\&
|
||||
.sp 10
|
||||
.ce 4
|
||||
DESCRIPTION OF A MACHINE
|
||||
ARCHITECTURE FOR USE WITH
|
||||
|
|
|
@ -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
|
||||
presupposes knowledge of the EM instruction set.
|
||||
.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.
|
||||
This register contains a pointer to a procedure.
|
||||
Initially the pointer used is zero and all traps halt the
|
||||
|
@ -124,7 +124,7 @@ ersave
|
|||
msave
|
||||
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
|
||||
ste jmpbuf+4
|
||||
lor 1 ; and SP
|
||||
|
@ -151,11 +151,11 @@ jmpbuf
|
|||
con *1,0,0
|
||||
end
|
||||
.DE 0
|
||||
.VS 1 1
|
||||
.VS
|
||||
.DS
|
||||
Example of catch procedure
|
||||
.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
|
||||
loc 4 ; check for overflow
|
||||
bne *1 ; if other trap, call higher trap procedure
|
||||
|
|
|
@ -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
|
||||
the object in \fIbits\fP.
|
||||
.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.
|
||||
The order of the bits within an object is knowingly left
|
||||
unspecified.
|
||||
|
@ -61,17 +62,23 @@ We assume existence of at least single word unsigned arithmetic
|
|||
in any implementation.
|
||||
.S2 "Signed Integers"
|
||||
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
|
||||
using two's complement arithmetic.
|
||||
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
|
||||
range \-2\v'-0.5m'\fBn\fP\-1\v'0.5m'~..~\-1.
|
||||
.Ex 2 "\fBn\fP\-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.
|
||||
The convert instructions between signed and unsigned integers
|
||||
of the same size can be used to catch errors.
|
||||
.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.
|
||||
EM implementations should trap when this value is used in an
|
||||
operation on signed integers.
|
||||
|
@ -80,7 +87,6 @@ can be used to disable such traps.
|
|||
.A
|
||||
We assume existence of at least single word signed arithmetic
|
||||
in any implementation.
|
||||
.BP
|
||||
.S2 "Floating point values"
|
||||
Floating point values must have a signed mantissa and a signed
|
||||
exponent.
|
||||
|
|
Loading…
Reference in a new issue