|
Optron #24
22 февраля 1999 |
|
Likbez - Assembler view from afar: Logical operations, operations AND, OR, XOR, NOT; mnemonics. Results of teams.

Assembler: a view from afar
{} Infarh
Continued. Home - a | | 20, 21
Logical operations
Sorting out the last time with arithmetic operations, go to
step logical. Unlike BASIC, in Assembler are equally important.
Those who are not familiar with the algebra of logic
I will say that its main difference from ordinary arithmetic is
that it actions are performed not over the whole number,
and over his bits - ie Transfer of Discharge
the discharge is not performed.
Z80 processor is able to perform the following logical
operations:
AND
OR
XOR
NOT
But not looking at the tables mnemonics
NOT - it is written as "CPL".
A look into the appointment of each logical operation will
help us a truth table.
AND operation
AND
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
The symbols A and B denote the operands, and Y
- Is the result.
In English, "AND" means "I".
As a chip that performs this
function that can lead 555LI1.
The essence of the operation "and" (logical multiplication)
can be derived from the following example.
Denote that you should read my article by Y = 1, and unread -
through the Y = 0. To get the result you need
perform two operations:
- Upload your Speccy "Optron" | 24
(If yes, then A = 1, and if not, then A = 0);
- Found in "Optocouplers" Field LIKBEZ (respectively, B = 1
or B = 0).
So, to get as a result of a logical "1", both operands as
must be equal to logic "1".
Here is the equation of this operation:
Y = A * B
OR operation
"OR" is translated as "OR". This operation is also called
"logical addition". Again we turn to the example.
To read my texts in
"Optocouplers" | 24 (ie, to obtain Y = 1), you
to select headings LIKBEZ (A = 1)
or LITSTRANICHKA (B = 1). Clearly, for
a positive result, one must be equal to either A or B, or
both together.
That is - a truth table for this operation:
OR
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
But - its equation:
Y = A + B
A sample of microcircuitry - 555LL1.
XOR operation
This - EXCLUSIVE OR.
Again, cite an example.
If you want, read my article BOTH play "Black Crow", I
I say:
"No, darling, after two hares chase - you will not catch! Y =
0!"
Respectively - and the truth table:
XOR
A B Y
0 0 0
0 1 1
1 0 1
1 1 0
In ordinary arithmetic, this operation is known as "the sum
modulo 2:
1 + 1 = 0
Similarly, in the decimal system with "summation modulo 10:
9 + 1 = 0
(In "addition modulo" transfer "is in the mind").
NOT operation
"NOT" means "not." This operation - not
simple, but very simple. It is
only on one operand and the changes it
meaning the opposite:
NOT
A Y
0 1
1 0
For lovers of equations:
_
Y = A
For "zhelezyachnikov: 555LN1.
We turn to the mnemonic
The impact of arithmetic operations on
a flag register, remind, does not cause problems ... But, then
she and logic to brains of the processor to soar! So now,
considering options for a mnemonic, we indicate the influence
of logical operations on flags:
Mnemonic Register F Bits
(Flags)
Operator
pa-Operand C Z P / V S N H
tion
AND r 0 x P x 0 1
AND (HL)
AND n
AND (ii + n)
OR r 0 x P x 0 0
OR (HL)
OR n
OR (ii + n)
XOR r 0 x P x 0 0
XOR (HL)
XOR n
XOR (ii + n)
CPL. . . . January 1
Legend:
Operations are always performed on the operand specified in
the table, and the contents of the battery;
"." - Flag is not changed as a result of the operation;
"X" - flag is set depending
on the result of the operation;
Other designations - see | 21.
The results of the commands (examples)
When you run
AND E
have an operation "and" over the contents of
Register "A" and "E". Let's say they have
the following values:
A = 10011010
E = 01111001
In this case we have, according to the truth table for AND,
we get:
1 0 0 1 1 0 1 0
AND
0 1 1 1 1 0 0 1
0 0 0 1 1 0 0 0
The result "00011000" is stored in the battery. "E" does not
change its value.
Similarly, when executing commands
OR
and
XOR
with the same values of the operands, we obtain:
1 0 0 1 1 0 1 0
OR
0 1 1 1 1 0 0 1
1 1 1 1 1 0 1 1
1 0 0 1 1 0 1 0
XOR
0 1 1 1 1 0 0 1
1 1 1 0 0 0 1 1
Team "CPL" (Operation "NOT", are not forgotten?) Is on one
operand - contents of register "A". That's what will
after its execution:
1 0 0 1 1 0 1 0
CPL
0 1 1 0 0 1 0 1
Since logical operations - everything. To be continued.
Other articles:
ZX-waggons - Overview of electronic media: ZX-News in 1942, Don News 1, Nicron 106, ZX-Pilot 30. |
entire life of the game - The latter II: Villains close. |
Likbez - Assembler view from afar: Logical operations, operations AND, OR, XOR, NOT; mnemonics. Results of teams. |
Lit. Page - Grief "Y-II" (Diary). |
Advertising - Advertisements and announcements ... |
Category X - Farewell of Slav. |
Similar articles:
В этот день... 27 October