Assembler language course - command system of the Z80 processor (part 5).

(C) WLODEK BLACK

Hello friends! After the release of the 4th NICRON there was a resurgence
nans - they sent me two letters with the same question:
what kind of processor is this Z380?!
Dear colleagues, you are absolutely right: if you said “A”, say “B”.
But, unfortunately, I have nothing to answer yet. On Saturday November 2nd I
I will meet with Yegor Voznesensky, and only after that I will have
there is news. On previous visits I saw his book "Z380 CPU"
publications of the Zilog Corporation. If Yegor agrees to give it to me
read, there will be a lot of news. Otherwise, there will be less news, but
they will be there anyway. Thank you all for your attention! Wait
next issue of the newspaper! Now let's continue with the lesson...

	    004h. PROCESSOR COMMAND SYSTEM Z80A.

   The command system is understood as a list of groups of existing
teams united by meaning and purpose. The following are distinguished:
command groups:
- information exchange: downloading, sending data;
- control the progress of the program: transfer of control (transitions),
  calls to subroutines, organization of cycles, etc.;
- arithmetic and logical commands; shift commands;
- input-output;
- special.

   The above division is quite arbitrary and subjective. Various
the authors have different views on grouping commands, but in general
everyone agrees on approximately this interpretation.
   The Z80 processor instruction set may seem sufficient
complex - it contains158 original (that is, self-
meaningful) commands;
taking into account their modifications and other “variations” the Z80 has 696 commands,
and then only those published by the processor developer.  Numerous
nal research in the 80s (here we need special thanks
express to the Polish “hackers”) revealed another whole group of unpublished
forged, but uniquely performed by the processor operations. About the mass
headquarters, the work done can be judged by at least this fact:
enthusiasts discovered a new process, unknown to the authors themselves.
ra, way of addressing! In a special appendix to our course
we will introduce you to some interesting "underground" teams
ladies. ...For comparison: the Intel 8088 IBM PC/XT processor has
100 original commands and 300 operation codes. However, to study as-
The Z80 sampler is simpler than the PC sampler, mainly due to more
simple addressing system.
  We will study processor commands in order from simple
to the complex and trying, if possible, to start with the most commonly used
bim commands.

		005h. Data transfer commands.

   This group of commands is among the most important, because in order
in order to process data, it needs to be taken from somewhere, and then converted
whatever.
   All transfer commands use one common basis -
Monica - LD - from the word "load" - load.

			Addressing methods.

   This concept means a way of indicating the location
Deniasource and destination of data. There are the following types of ad-
resations:
- direct. The register is loaded with the byte specified in the sa-
  my team;
- register. The byte is sent from a single 8-bit register
  ra in another;
- straight. A byte is transferred from the accumulator register to memory
  or vice versa at the address specified directly in the command;
- indirect. A byte is transferred from a register to memory or vice versa
  at the address specified in the 16-bit register pair;
- index. The byte is sent to the address calculated as the sum
  base address values stored in index register IX
  or IY, and the offset included in the command.
Some definitions may have the word "extended" added to them.
Extended addressing involves operating with a 2-byte
data.
Sometimes implicit addressing is also mentioned. It takes place in the team
data, always using the same sources and receivers of data
nykh.

   In all cases of writing transfer commands and other actions,
when the instruction contains a source operand and a destination operand
nik, the receiver is indicated in the first place, and the source in the second place.
nickname For example, LD A,E - means send the contents of the register
E into the battery, and not vice versa. The logic of such a standard has become
no, it’s clear if you look at any team in which the second
operand is a constant included in the command:
ADD A,64 - add the contents of the battery withnumber 64, result
place in battery.

   In all double operations the fundamental rule is accepted:
the contents of the second operand (source) as a result of the operation
does not change.

   Many byte addressing methods are also used for forwarding
16-bit data. Most addressing methods are suitable and
for arithmetic, logical operations, shift operations, co-
transition mands, etc.

		8-bit transfer instructions.

Between registers A, B, C, D, E, H, L, mutual transfers are possible in any
any combinations, for example, LD A,C;  LD E,L;  LD H,D.
   Shipping to a direct address is only possible for batteries:
LD A,(addr);  LD(addr),A.    Pay attention to the parentheses. Circle-
parentheses are used only as a sign that their internal
its contents are an address, not a constant.  Use
parentheses in arithmetic expressions to change the priority
theta operations are not possible.
   Indirect battery addressing can be done in pairs
HL,DE and BC:
LD A,(HL);  LD(DE),A;  L.D.(BC),A.
   Registers A, B, C, D, E can be addressed indirectly by (HL):
LD E,(HL); LD(HL),C; LD A,(HL).
Strictly speaking, the H and L registers are also no exception, but the constructions
type LD H,(HL), resulting in a change in address in ad-
relevant pair of registers - rather the field of activity of virtuosos from
assembler, not beginners.
   Indirect addressing is usually used in cases where the address
forwardingcalculated in the program, or to reduce the length
programs when frequently accessed at the same address, so
as instructions LD (HL),r (r is a general purpose register) and similar
personal ones are single-byte.
   You can also enter a constant at the address (HL): LD (HL),d8 (d8 -
8-bit number).
   Index addressing is carried out based on the addition of base-
th address from the 16-bit register IX or IY with an 8-bit shift
member of the team. The offset byte is third
they are accounted for in the full command code. The whole team can be three
byte - for sending the contents of the register and four-byte
- to enter constants into a RAM cell. Examples:
LD E,(IX+0); LD(IY-5),07FH; LD (IX+REMOVE),A.  In the last
At least the name-identifier is used as the offset operand.
torus How to use names - identifiers and labels, we
we'll talk soon.
   The value of the offset byte included in the command with index-
nal addressing, is treated as a 7-bit signed integer.
That is, access is possible to the memory area in the section -128...+127
relative to the value of the index register. When writing the command
you can use the minus sign; the assembler itself will calculate the corresponding
current byte.
   Index addressing is possible for A,B,C,D,E,H,L,d8.Not possible
execution LD (IX+nn),(HL); LD (IX+nn),(IY+mm), etc., that is
"index-indirect" and "index-index" addressingabsent.
   Attention! Experimenting with index addressing on a computer
re "Spectrum", do not change the value of the IY register! At Spectrum
IY is constantly used by the operating system, and modification
its contents will inevitably lead to failure.

   The currently studied methods for addressing a byte multiple times are
but we will meet them later in arithmetic, logical,
shear operations, so try to understand them well

Share your thoughts about the article