*** empty log message ***
This commit is contained in:
parent
e4e29ae837
commit
fb6d291d38
2 changed files with 84 additions and 67 deletions
118
doc/i80.doc
118
doc/i80.doc
|
@ -1,4 +1,3 @@
|
||||||
." $Header$
|
|
||||||
.RP
|
.RP
|
||||||
.TL
|
.TL
|
||||||
Back end table for the Intel 8080 micro-processor
|
Back end table for the Intel 8080 micro-processor
|
||||||
|
@ -97,15 +96,11 @@ The 8080 microprocessor provides five flip-flops used as condition flags
|
||||||
.br
|
.br
|
||||||
The sign bit S is set (cleared) by certain instructions when the most significant
|
The sign bit S is set (cleared) by certain instructions when the most significant
|
||||||
bit of the result of an operation equals one (zero).
|
bit of the result of an operation equals one (zero).
|
||||||
.br
|
|
||||||
The zero bit Z is set (cleared) by certain operations when the
|
The zero bit Z is set (cleared) by certain operations when the
|
||||||
8-bit result of an operation equals (does not equal) zero.
|
8-bit result of an operation equals (does not equal) zero.
|
||||||
.br
|
|
||||||
The parity bit P is set (cleared) if the 8-bit result of an
|
The parity bit P is set (cleared) if the 8-bit result of an
|
||||||
operation includes an even (odd) number of ones.
|
operation includes an even (odd) number of ones.
|
||||||
.br
|
|
||||||
C is the normal carry bit.
|
C is the normal carry bit.
|
||||||
.br
|
|
||||||
AC is an auxiliary carry that indicates whether there has been a carry
|
AC is an auxiliary carry that indicates whether there has been a carry
|
||||||
out of bit 3 of the accumulator.
|
out of bit 3 of the accumulator.
|
||||||
This auxiliary carry is used only by the DAA instruction, which
|
This auxiliary carry is used only by the DAA instruction, which
|
||||||
|
@ -130,14 +125,12 @@ of register-pair HL.
|
||||||
.NH 3
|
.NH 3
|
||||||
Register addressing
|
Register addressing
|
||||||
.PP
|
.PP
|
||||||
|
With each instruction using register addressing,
|
||||||
With each intruction using register addressing,
|
|
||||||
only one register is specified (except for the MOV instruction),
|
only one register is specified (except for the MOV instruction),
|
||||||
although in many of them the accumulator is implied as
|
although in many of them the accumulator is implied as
|
||||||
second operand.
|
second operand.
|
||||||
Examples are CMP E, which compares register E with the accumulator,
|
Examples are CMP E, which compares register E with the accumulator,
|
||||||
and DCR B, which decrements register B.
|
and DCR B, which decrements register B.
|
||||||
.br
|
|
||||||
A few instructions deal with 16 bit register-pairs:
|
A few instructions deal with 16 bit register-pairs:
|
||||||
examples are DCX B, which decrements register-pair BC and the
|
examples are DCX B, which decrements register-pair BC and the
|
||||||
PUSH and POP instructions.
|
PUSH and POP instructions.
|
||||||
|
@ -173,7 +166,7 @@ The high order byte is stored at the highest address.
|
||||||
THE 8080 BACK END TABLE
|
THE 8080 BACK END TABLE
|
||||||
.PP
|
.PP
|
||||||
The back end table is designed as described in [5].
|
The back end table is designed as described in [5].
|
||||||
So for an overall design of a back end table I refer to this document.
|
For an overall design of a back end table I refer to this document.
|
||||||
.br
|
.br
|
||||||
This section deals with problems encountered in writing the
|
This section deals with problems encountered in writing the
|
||||||
8080 back-end table.
|
8080 back-end table.
|
||||||
|
@ -185,30 +178,30 @@ Constant definitions
|
||||||
Word size (EM_WSIZE) and pointer size (EM_PSIZE) are both
|
Word size (EM_WSIZE) and pointer size (EM_PSIZE) are both
|
||||||
defined as two bytes.
|
defined as two bytes.
|
||||||
The hole between AB and LB (EM_BSIZE) is four bytes: only the
|
The hole between AB and LB (EM_BSIZE) is four bytes: only the
|
||||||
return address and the localbase are saved.
|
return address and the local base are saved.
|
||||||
.NH 2
|
.NH 2
|
||||||
Registers and their properties
|
Registers and their properties
|
||||||
.PP
|
.PP
|
||||||
All properties have the default size of two bytes, because one-byte
|
All properties have the default size of two bytes, because one-byte
|
||||||
registers also cover two bytes when put on the real stack.
|
registers also cover two bytes when put on the real stack.
|
||||||
.sp 1
|
.sp 1
|
||||||
The next considerations led to the choise of register-pair BC
|
The next considerations led to the choice of register-pair BC
|
||||||
as localbase.
|
as local base.
|
||||||
Though saving the localbase in memory would leave one more register-pair
|
Though saving the local base in memory would leave one more register-pair
|
||||||
available as scratch register, it would slow down instructions
|
available as scratch register, it would slow down instructions
|
||||||
as 'lol' and 'stl' too much.
|
as 'lol' and 'stl' too much.
|
||||||
So a register-pair should be sacrificed as localbase.
|
So a register-pair should be sacrificed as local base.
|
||||||
Because a back-end without a free register-pair HL is completely
|
Because a back-end without a free register-pair HL is completely
|
||||||
broken-winged, the only reasonable choises are BC and DE.
|
broken-winged, the only reasonable choices are BC and DE.
|
||||||
Though the choise between them might seem arbitrary at first sight,
|
Though the choice between them might seem arbitrary at first sight,
|
||||||
there is a difference between register-pairs BC and DE:
|
there is a difference between register-pairs BC and DE:
|
||||||
the instruction XCHG exchanges the contents of register-pairs DE and
|
the instruction XCHG exchanges the contents of register-pairs DE and
|
||||||
HL.
|
HL.
|
||||||
When DE and HL are both heavily used on the fake-stack, this instruction
|
When DE and HL are both heavily used on the fake-stack, this instruction
|
||||||
is very usefull.
|
is very useful.
|
||||||
Since it won't be usefull too often to exchange HL with the localbase
|
Since it won't be useful too often to exchange HL with the local base
|
||||||
and since an instruction exchanging BC and HL does not exist, BC is
|
and since an instruction exchanging BC and HL does not exist, BC is
|
||||||
chosen as localbase.
|
chosen as local base.
|
||||||
.sp 1
|
.sp 1
|
||||||
Many of the register properties are never mentioned in the
|
Many of the register properties are never mentioned in the
|
||||||
PATTERNS part of the table.
|
PATTERNS part of the table.
|
||||||
|
@ -219,7 +212,7 @@ The properties really used in the PATTERNS part are:
|
||||||
the accumulator only
|
the accumulator only
|
||||||
.IP reg:
|
.IP reg:
|
||||||
any of the registers A, D, E, H or L. Of course the registers B and C which are
|
any of the registers A, D, E, H or L. Of course the registers B and C which are
|
||||||
used as localbase don't possess this property.
|
used as local base don't possess this property.
|
||||||
When there is a single register on the fake-stack, its value
|
When there is a single register on the fake-stack, its value
|
||||||
is always considered non-negative.
|
is always considered non-negative.
|
||||||
.IP dereg:
|
.IP dereg:
|
||||||
|
@ -228,12 +221,12 @@ register-pair DE only
|
||||||
register-pair HL only
|
register-pair HL only
|
||||||
.IP hl_or_de:
|
.IP hl_or_de:
|
||||||
register-pairs HL and DE both have this property
|
register-pairs HL and DE both have this property
|
||||||
.IP localbase:
|
.IP local base:
|
||||||
used only once (i.e. in the EM-instruction 'str 0')
|
used only once (i.e. in the EM-instruction 'str 0')
|
||||||
.PP
|
.PP
|
||||||
.sp 1
|
.sp 1
|
||||||
The stackpointer SP and the processor status word PSW have to be
|
The stackpointer SP and the processor status word PSW have to be
|
||||||
defined explicitely because they are needed in some instructions
|
defined explicitly because they are needed in some instructions
|
||||||
(i.e. SP in LXI, DCX and INX and PSW in PUSH and POP).
|
(i.e. SP in LXI, DCX and INX and PSW in PUSH and POP).
|
||||||
.br
|
.br
|
||||||
It doesn't matter that the processor status word is not just register A
|
It doesn't matter that the processor status word is not just register A
|
||||||
|
@ -252,7 +245,6 @@ Compared with many other back-end tables, there are only a small number of
|
||||||
different tokens (four).
|
different tokens (four).
|
||||||
Reasons are the limited addressing modes of the 8080 microprocessor,
|
Reasons are the limited addressing modes of the 8080 microprocessor,
|
||||||
no index registers etc.
|
no index registers etc.
|
||||||
.br
|
|
||||||
For example to translate the EM-instruction
|
For example to translate the EM-instruction
|
||||||
.DS
|
.DS
|
||||||
lol 10
|
lol 10
|
||||||
|
@ -260,16 +252,15 @@ lol 10
|
||||||
the next 8080 instructions are generated:
|
the next 8080 instructions are generated:
|
||||||
.DS L
|
.DS L
|
||||||
LXI H,10 /* load registers pair HL with value 10 */
|
LXI H,10 /* load registers pair HL with value 10 */
|
||||||
DAD B /* add localbase (BC) to HL */
|
DAD B /* add local base (BC) to HL */
|
||||||
MOV E,M /* load E with byte pointed to by HL */
|
MOV E,M /* load E with byte pointed to by HL */
|
||||||
INX H /* increment HL */
|
INX H /* increment HL */
|
||||||
MOV D,M /* load D with next byte */
|
MOV D,M /* load D with next byte */
|
||||||
.DE
|
.DE
|
||||||
Of course, instead of emitting code immmediately, it could be postponed
|
Of course, instead of emitting code immediately, it could be postponed
|
||||||
by placing something like a {LOCAL,10} on the fake-stack, but some day the above
|
by placing something like a {LOCAL,10} on the fake-stack, but some day the above
|
||||||
mentioned code will have to be generated, so a LOCAL-token is
|
mentioned code will have to be generated, so a LOCAL-token is
|
||||||
hardly usefull.
|
hardly useful.
|
||||||
.br
|
|
||||||
See also the comment on the load instructions.
|
See also the comment on the load instructions.
|
||||||
.NH 2
|
.NH 2
|
||||||
Sets
|
Sets
|
||||||
|
@ -295,13 +286,13 @@ In fact it usually takes 3 extra time periods when this register indirect mode
|
||||||
is used instead of register mode, but since the costs are not completely
|
is used instead of register mode, but since the costs are not completely
|
||||||
orthogonal this results in small deficiencies for the DCR, INR and MOV
|
orthogonal this results in small deficiencies for the DCR, INR and MOV
|
||||||
instructions.
|
instructions.
|
||||||
Although it is not particularly usefull these deficiencies are
|
Although it is not particularly useful these deficiencies are
|
||||||
corrected in the INSTRUCTIONS part, by treating the register indirect
|
corrected in the INSTRUCTIONS part, by treating the register indirect
|
||||||
mode seperately.
|
mode separately.
|
||||||
.sp 1
|
.sp 1
|
||||||
The costs of the conditional call and return instructions really
|
The costs of the conditional call and return instructions really
|
||||||
depend on whether or not the call resp. return is actually made.
|
depend on whether or not the call resp. return is actually made.
|
||||||
Unimportant.
|
However, this is not important to the behaviour of the back end.
|
||||||
.sp 1
|
.sp 1
|
||||||
Instructions not used in this table have been commented out.
|
Instructions not used in this table have been commented out.
|
||||||
Of course many of them are used in the library routines.
|
Of course many of them are used in the library routines.
|
||||||
|
@ -316,7 +307,7 @@ The TESTS section is only included to refrain
|
||||||
.B cgg
|
.B cgg
|
||||||
from complaining.
|
from complaining.
|
||||||
.NH 2
|
.NH 2
|
||||||
Stackingrules
|
Stacking rules
|
||||||
.PP
|
.PP
|
||||||
When, for example, the token {const2,10} has to be stacked while
|
When, for example, the token {const2,10} has to be stacked while
|
||||||
no free register-pair is available, the next code is generated:
|
no free register-pair is available, the next code is generated:
|
||||||
|
@ -341,12 +332,11 @@ this instruction in fact exchanges the contents of these
|
||||||
register-pairs.
|
register-pairs.
|
||||||
Before the coercion is carried out other appearances of DE and HL
|
Before the coercion is carried out other appearances of DE and HL
|
||||||
on the fake-stack will be moved to the real stack, because in
|
on the fake-stack will be moved to the real stack, because in
|
||||||
the INSTRUCTION-part is told that XCHG destroyes the contents
|
the INSTRUCTION-part is told that XCHG destroys the contents
|
||||||
of both DE and HL.
|
of both DE and HL.
|
||||||
.br
|
|
||||||
The coercion transposing one register-pair to another one by
|
The coercion transposing one register-pair to another one by
|
||||||
emitting two MOV-instructions, will be used only if
|
emitting two MOV-instructions, will be used only if
|
||||||
one of the register-pairs is the localbase.
|
one of the register-pairs is the local base.
|
||||||
.NH 2
|
.NH 2
|
||||||
Patterns
|
Patterns
|
||||||
.PP
|
.PP
|
||||||
|
@ -361,7 +351,7 @@ gen lhld {label,$1} yields hl
|
||||||
.DE
|
.DE
|
||||||
the 'uses'-clause could have been omitted because
|
the 'uses'-clause could have been omitted because
|
||||||
.B cgg
|
.B cgg
|
||||||
knows that LHLD destroyes register-pair HL.
|
knows that LHLD destroys register-pair HL.
|
||||||
.sp 1
|
.sp 1
|
||||||
Since there is only one register with property 'hlreg',
|
Since there is only one register with property 'hlreg',
|
||||||
there is no difference between 'uses hlreg' (allocate a
|
there is no difference between 'uses hlreg' (allocate a
|
||||||
|
@ -369,7 +359,7 @@ register with property 'hlreg') and 'kills hlreg' (remove
|
||||||
all registers with property 'hlreg' from the fake-stack).
|
all registers with property 'hlreg' from the fake-stack).
|
||||||
The same applies for the property 'dereg'.
|
The same applies for the property 'dereg'.
|
||||||
.br
|
.br
|
||||||
As a consequence 'kills' is rarely used in this back-end table.
|
Consequently 'kills' is rarely used in this back-end table.
|
||||||
.NH 3
|
.NH 3
|
||||||
Group 1: Load instructions
|
Group 1: Load instructions
|
||||||
.PP
|
.PP
|
||||||
|
@ -385,7 +375,6 @@ To refrain
|
||||||
.B cgg
|
.B cgg
|
||||||
from emitting the code for 'lol 10' again, an extra
|
from emitting the code for 'lol 10' again, an extra
|
||||||
pattern is included in the table for cases like this.
|
pattern is included in the table for cases like this.
|
||||||
.br
|
|
||||||
The same applies for two consecutive 'loe'-s or 'lil'-s.
|
The same applies for two consecutive 'loe'-s or 'lil'-s.
|
||||||
.sp 1
|
.sp 1
|
||||||
A bit tricky is 'lof'.
|
A bit tricky is 'lof'.
|
||||||
|
@ -401,7 +390,7 @@ knows that HL is destroyed).
|
||||||
.sp 1
|
.sp 1
|
||||||
By lookahead,
|
By lookahead,
|
||||||
.B cgg
|
.B cgg
|
||||||
can make a clever choise between the first and
|
can make a clever choice between the first and
|
||||||
second code rule of 'loi 4'.
|
second code rule of 'loi 4'.
|
||||||
The same applies for several other instructions.
|
The same applies for several other instructions.
|
||||||
.NH 3
|
.NH 3
|
||||||
|
@ -415,13 +404,12 @@ Groups 3 and 4: Signed and unsigned integer arithmetic
|
||||||
Since the 8080 instruction set doesn't provide multiply and
|
Since the 8080 instruction set doesn't provide multiply and
|
||||||
divide instructions, special routines are made to accomplish these tasks.
|
divide instructions, special routines are made to accomplish these tasks.
|
||||||
.sp 1
|
.sp 1
|
||||||
Instead of providing four slighty differing routines for 16 bit signed or
|
Instead of providing four slightly differing routines for 16 bit signed or
|
||||||
unsigned division, yielding the quotient or the remainder,
|
unsigned division, yielding the quotient or the remainder,
|
||||||
the routines are merged.
|
the routines are merged.
|
||||||
This saves space and assembly time
|
This saves space and assembly time
|
||||||
when several variants are used in a particular program,
|
when several variants are used in a particular program,
|
||||||
at the cost of a little speed.
|
at the cost of a little speed.
|
||||||
.br
|
|
||||||
When the routine is called, bit 7 of register A indicates whether
|
When the routine is called, bit 7 of register A indicates whether
|
||||||
the operands should be considered as signed or as unsigned integers,
|
the operands should be considered as signed or as unsigned integers,
|
||||||
and bit 0 of register A indicates whether the quotient or the
|
and bit 0 of register A indicates whether the quotient or the
|
||||||
|
@ -436,14 +424,15 @@ provided, because this one will usually be much faster.
|
||||||
.NH 3
|
.NH 3
|
||||||
Group 5: Floating point arithmetic
|
Group 5: Floating point arithmetic
|
||||||
.PP
|
.PP
|
||||||
Floating points are not implemented.
|
Floating point is not implemented.
|
||||||
.br
|
|
||||||
Whenever an EM-instruction involving floating points is offered
|
Whenever an EM-instruction involving floating points is offered
|
||||||
to the code-generator, it generates the code 'call eunimpl',
|
to the code-generator, it calls the corresponding
|
||||||
which traps with trap number 63.
|
library routine with the proper parameters.
|
||||||
|
Each floating point library routine calls 'eunimpl',
|
||||||
|
trapping with trap number 63.
|
||||||
Some of the Pascal and C library routines output floating point
|
Some of the Pascal and C library routines output floating point
|
||||||
EM-instructions, so code has to be generated for them.
|
EM-instructions, so code has to be generated for them.
|
||||||
Of course this doesn't imply the code will ever be executed.
|
Of course this does not imply the code will ever be executed.
|
||||||
.NH 3
|
.NH 3
|
||||||
Group 12: Compare instructions
|
Group 12: Compare instructions
|
||||||
.PP
|
.PP
|
||||||
|
@ -468,7 +457,6 @@ gen mov a,%1.2
|
||||||
but the current version of
|
but the current version of
|
||||||
.B cgg
|
.B cgg
|
||||||
doesn't approve this.
|
doesn't approve this.
|
||||||
.br
|
|
||||||
In any case
|
In any case
|
||||||
.B cgg
|
.B cgg
|
||||||
chooses either DE or HL to store the result, using lookahead.
|
chooses either DE or HL to store the result, using lookahead.
|
||||||
|
@ -481,7 +469,7 @@ If only 2 bytes have to be returned, register-pair DE is used.
|
||||||
LIBRARY ROUTINES
|
LIBRARY ROUTINES
|
||||||
.PP
|
.PP
|
||||||
Most of the library routines start with saving the return address
|
Most of the library routines start with saving the return address
|
||||||
and the localbase, so that the parameters are on the top of the stack
|
and the local base, so that the parameters are on the top of the stack
|
||||||
and the registers B and C are available as scratch registers.
|
and the registers B and C are available as scratch registers.
|
||||||
Since register-pair HL is needed to accomplish these tasks,
|
Since register-pair HL is needed to accomplish these tasks,
|
||||||
and also to restore everything just before the routine returns,
|
and also to restore everything just before the routine returns,
|
||||||
|
@ -493,7 +481,6 @@ When a routine returns 2 bytes, they are usually returned in
|
||||||
registers-pair DE.
|
registers-pair DE.
|
||||||
When it returns more than 2 bytes they are pushed onto the stack.
|
When it returns more than 2 bytes they are pushed onto the stack.
|
||||||
.br
|
.br
|
||||||
|
|
||||||
It would have been possible to let the 32 bit arithmetic routines
|
It would have been possible to let the 32 bit arithmetic routines
|
||||||
return 2 bytes in DE and the remaining 2 bytes on the stack
|
return 2 bytes in DE and the remaining 2 bytes on the stack
|
||||||
(this often would have saved some space and execution time),
|
(this often would have saved some space and execution time),
|
||||||
|
@ -504,7 +491,6 @@ TRAPS
|
||||||
Whenever a trap, for example trying to divide by zero,
|
Whenever a trap, for example trying to divide by zero,
|
||||||
occurs in a program that originally was written in C or Pascal,
|
occurs in a program that originally was written in C or Pascal,
|
||||||
a special trap handler is called.
|
a special trap handler is called.
|
||||||
.br
|
|
||||||
This trap handler wants to write an appropriate error message on the
|
This trap handler wants to write an appropriate error message on the
|
||||||
monitor.
|
monitor.
|
||||||
It tries to read the message from a file (e.g. etc/pc_rt_errors in the
|
It tries to read the message from a file (e.g. etc/pc_rt_errors in the
|
||||||
|
@ -549,11 +535,11 @@ for example by downloading or
|
||||||
by storing it in ROM (Read Only Memory).
|
by storing it in ROM (Read Only Memory).
|
||||||
.sp 1
|
.sp 1
|
||||||
Depending on the characteristics of the particular 8080 based system, some
|
Depending on the characteristics of the particular 8080 based system, some
|
||||||
adaptions have to be made:
|
adaptations have to be made:
|
||||||
.IP 1) 10
|
.IP 1) 10
|
||||||
In 'head_em': the base address, which is the address where the first
|
In 'head_em': the base address, which is the address where the first
|
||||||
8080 instruction will be stored, and the initial value of the
|
8080 instruction will be stored, and the initial value of the
|
||||||
stackpointer are set to 0x1000 and 0x8000 respectivally.
|
stackpointer are set to 0x1000 and 0x8000 respectively.
|
||||||
.br
|
.br
|
||||||
Other systems require other values.
|
Other systems require other values.
|
||||||
.IP 2)
|
.IP 2)
|
||||||
|
@ -574,12 +560,12 @@ If this is not the right way on your system, change it.
|
||||||
.IP 5)
|
.IP 5)
|
||||||
In 'tail_em': the current version of the 8080 back-end has very limited I/O
|
In 'tail_em': the current version of the 8080 back-end has very limited I/O
|
||||||
capabilities, because it was tested on a system that
|
capabilities, because it was tested on a system that
|
||||||
had no knowlegde of files.
|
had no knowledge of files.
|
||||||
So the implementation of the EM-instruction 'mon' is very simple;
|
So the implementation of the EM-instruction 'mon' is very simple;
|
||||||
it can only do the following things:
|
it can only do the following things:
|
||||||
.RS
|
.RS
|
||||||
.IP Monitor\ call\ 1: 40
|
.IP Monitor\ call\ 1: 40
|
||||||
Exit
|
exit
|
||||||
.IP Monitor\ call\ 3:
|
.IP Monitor\ call\ 3:
|
||||||
read, always reads from the monitor.
|
read, always reads from the monitor.
|
||||||
.br
|
.br
|
||||||
|
@ -607,7 +593,7 @@ INTEL 8080 VERSUS ZILOG Z80 AND INTEL 8086
|
||||||
.NH 2
|
.NH 2
|
||||||
Introduction
|
Introduction
|
||||||
.PP
|
.PP
|
||||||
At about the same time I develloped the back end
|
At about the same time I developed the back end
|
||||||
for the Intel 8080 and Intel 8085,
|
for the Intel 8080 and Intel 8085,
|
||||||
Frans van Haarlem did the same job for the Zilog z80 microprocessor.
|
Frans van Haarlem did the same job for the Zilog z80 microprocessor.
|
||||||
Since the z80 processor is an extension of the 8080,
|
Since the z80 processor is an extension of the 8080,
|
||||||
|
@ -615,8 +601,8 @@ any machine code offered to a 8080 processor can be offered
|
||||||
to a z80 too.
|
to a z80 too.
|
||||||
The assembly languages are quite different however.
|
The assembly languages are quite different however.
|
||||||
.br
|
.br
|
||||||
During the devellopments of the back ends we have used
|
During the developments of the back ends we have used
|
||||||
two micro-computers, both equiped with a z80 microprocessor.
|
two micro-computers, both equipped with a z80 microprocessor.
|
||||||
Of course the output of the 8080 back end is assembled by an
|
Of course the output of the 8080 back end is assembled by an
|
||||||
8080 assembler. This should assure I have never used any of
|
8080 assembler. This should assure I have never used any of
|
||||||
the features that are potentially available in the z80 processor,
|
the features that are potentially available in the z80 processor,
|
||||||
|
@ -632,7 +618,7 @@ I have also involved the 8086 micro-processor in this measurements.
|
||||||
Differences between the 8080 and z80 processors
|
Differences between the 8080 and z80 processors
|
||||||
.PP
|
.PP
|
||||||
Except for some features that are less important concerning back ends,
|
Except for some features that are less important concerning back ends,
|
||||||
there are two points where the z80 improves the 8080:
|
there are two points where the z80 improves upon the 8080:
|
||||||
.IP First, 18
|
.IP First, 18
|
||||||
the z80 has two additional index registers, IX and IY.
|
the z80 has two additional index registers, IX and IY.
|
||||||
They are used as in
|
They are used as in
|
||||||
|
@ -662,11 +648,10 @@ Special routines are included to jump to near locations, saving 1 byte.
|
||||||
Consequences for the 8080 and z80 back end
|
Consequences for the 8080 and z80 back end
|
||||||
.PP
|
.PP
|
||||||
The most striking difference between the 8080 and z80 back ends
|
The most striking difference between the 8080 and z80 back ends
|
||||||
is the choise of the localbase.
|
is the choice of the local base.
|
||||||
The writer of the z80 back end chose index register IY as localbase,
|
The writer of the z80 back end chose index register IY as local base,
|
||||||
because this results in the cheapest coding of EM-instructions
|
because this results in the cheapest coding of EM-instructions
|
||||||
like 'lol' and 'stl'.
|
like 'lol' and 'stl'.
|
||||||
.br
|
|
||||||
The z80 instructions that load local 10, for example
|
The z80 instructions that load local 10, for example
|
||||||
.DS
|
.DS
|
||||||
LD E,(IY+10)
|
LD E,(IY+10)
|
||||||
|
@ -679,7 +664,7 @@ Although the profit of the z80 might be not world-shocking,
|
||||||
it should be noted that as a side effect it may save some
|
it should be noted that as a side effect it may save some
|
||||||
pushing and popping since register pair HL is not used.
|
pushing and popping since register pair HL is not used.
|
||||||
.sp 1
|
.sp 1
|
||||||
The choise of IY as localbase has its drawbacks too.
|
The choice of IY as local base has its drawbacks too.
|
||||||
The root of the problem is that it is not possible to add
|
The root of the problem is that it is not possible to add
|
||||||
IY to HL.
|
IY to HL.
|
||||||
For the EM-instruction
|
For the EM-instruction
|
||||||
|
@ -699,7 +684,7 @@ This annoying push and pop instructions are also needed in some
|
||||||
other instructions, for instance in 'lol' when the offset
|
other instructions, for instance in 'lol' when the offset
|
||||||
doesn't fit in one byte.
|
doesn't fit in one byte.
|
||||||
.sp 1
|
.sp 1
|
||||||
Beside the choise of the localbase, I think there is no
|
Beside the choice of the local base, I think there is no
|
||||||
fundamental difference between the 8080 and z80 back ends,
|
fundamental difference between the 8080 and z80 back ends,
|
||||||
except of course that the z80 back end has register pair BC
|
except of course that the z80 back end has register pair BC
|
||||||
and, less important, index register IX available as scratch registers.
|
and, less important, index register IX available as scratch registers.
|
||||||
|
@ -715,7 +700,6 @@ some C programs and some Pascal programs.
|
||||||
Then I produced 8080, z80 and 8086 code for them.
|
Then I produced 8080, z80 and 8086 code for them.
|
||||||
Investigating the assembler listing I found the
|
Investigating the assembler listing I found the
|
||||||
lengths of the different parts of the generated code.
|
lengths of the different parts of the generated code.
|
||||||
.br
|
|
||||||
I have checked two areas:
|
I have checked two areas:
|
||||||
.IP 1) 8
|
.IP 1) 8
|
||||||
the entire text part
|
the entire text part
|
||||||
|
@ -742,7 +726,7 @@ The table below should be read as follows.
|
||||||
For all programs I have computed the ratio of the code-lengths
|
For all programs I have computed the ratio of the code-lengths
|
||||||
of the 8080, z80 and 8086.
|
of the 8080, z80 and 8086.
|
||||||
The averages of all Pascal/C programs are listed in the table,
|
The averages of all Pascal/C programs are listed in the table,
|
||||||
standarized to '100' for the 8080.
|
standardized to '100' for the 8080.
|
||||||
So the listed '107' indicates that the lengths
|
So the listed '107' indicates that the lengths
|
||||||
of the text parts of the z80 programs that originally were Pascal programs,
|
of the text parts of the z80 programs that originally were Pascal programs,
|
||||||
averaged 7 percent larger than in the corresponding 8080 programs.
|
averaged 7 percent larger than in the corresponding 8080 programs.
|
||||||
|
@ -760,7 +744,7 @@ averaged 7 percent larger than in the corresponding 8080 programs.
|
||||||
The most striking thing in this table is that the z80 back end appears
|
The most striking thing in this table is that the z80 back end appears
|
||||||
to produce larger code than the 8080 back end.
|
to produce larger code than the 8080 back end.
|
||||||
The reason is that the current z80 back end table is
|
The reason is that the current z80 back end table is
|
||||||
not very elaborate yet.
|
not very sophisticated yet.
|
||||||
For instance it doesn't look for any EM-pattern longer than one.
|
For instance it doesn't look for any EM-pattern longer than one.
|
||||||
So the table shows that the preparations in the 8080 back end table
|
So the table shows that the preparations in the 8080 back end table
|
||||||
to produce faster code (like recognizing special EM-patterns
|
to produce faster code (like recognizing special EM-patterns
|
||||||
|
@ -768,7 +752,7 @@ and permitting one byte registers on the fake-stack)
|
||||||
was not just for fun, but really improved the generated code
|
was not just for fun, but really improved the generated code
|
||||||
significantly.
|
significantly.
|
||||||
.sp 1
|
.sp 1
|
||||||
The table shows that the 8080 table is relativelly better
|
The table shows that the 8080 table is relatively better
|
||||||
when only the plain user program is considered instead of the entire text part.
|
when only the plain user program is considered instead of the entire text part.
|
||||||
This is not very surprising since the 8080 back end sometimes
|
This is not very surprising since the 8080 back end sometimes
|
||||||
uses library routines where the z80 and especially the 8086 don't.
|
uses library routines where the z80 and especially the 8086 don't.
|
||||||
|
@ -797,7 +781,7 @@ An overview on the Amsterdam Compiler Kit.
|
||||||
.IP [3]
|
.IP [3]
|
||||||
Tanenbaum, A.S., Stevenson, J.W., Keizer, E.G., and van Staveren, H.
|
Tanenbaum, A.S., Stevenson, J.W., Keizer, E.G., and van Staveren, H.
|
||||||
.br
|
.br
|
||||||
Desciption of an experimental machine architecture for use with block
|
Description of an experimental machine architecture for use with block
|
||||||
structured languages,
|
structured languages,
|
||||||
.br
|
.br
|
||||||
Informatica report 81, Vrije Universiteit, Amsterdam, 1983.
|
Informatica report 81, Vrije Universiteit, Amsterdam, 1983.
|
||||||
|
|
33
mach/i80/libem/flp.s
Normal file
33
mach/i80/libem/flp.s
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
.define .adf4,.adf8,.sbf4,.sbf8,.mlf4,.mlf8,.dvf4,.dvf8
|
||||||
|
.define .ngf4,.ngf8,.fif4,.fif8,.fef4,.fef8
|
||||||
|
.define .zrf4,.zrf8
|
||||||
|
.define .cfi,.cif,.cuf,.cff,.cfu
|
||||||
|
.define .cmf4,.cmf8
|
||||||
|
|
||||||
|
! Floating point is not implemented
|
||||||
|
|
||||||
|
.adf4:
|
||||||
|
.adf8:
|
||||||
|
.sbf4:
|
||||||
|
.sbf8:
|
||||||
|
.mlf4:
|
||||||
|
.mlf8:
|
||||||
|
.dvf4:
|
||||||
|
.dvf8:
|
||||||
|
.ngf4:
|
||||||
|
.ngf8:
|
||||||
|
.fif4:
|
||||||
|
.fif8:
|
||||||
|
.fef4:
|
||||||
|
.fef8:
|
||||||
|
.zrf4:
|
||||||
|
.zrf8:
|
||||||
|
.cfi:
|
||||||
|
.cif:
|
||||||
|
.cuf:
|
||||||
|
.cff:
|
||||||
|
.cfu:
|
||||||
|
.cmf4:
|
||||||
|
.cmf8:
|
||||||
|
call eunimpl
|
||||||
|
ret
|
Loading…
Reference in a new issue