PIXel/Brutal Creators 02/11/2000 Med 3.01
__________________________________________
Nowadays, wherever you go, they teach you how to
make very-bid-super-teda-fast-ultra-
procedur, why the fuck for a beginner
this procedure is for the coder, he has the brains to
will stick to the skull until he understands how she
works. That's why I decided to share with
them with the simple truths of coding.
Logical operators and their application.
This article is dedicated to all those heroes
which nocatb programs manage to fail
having fully understood the principles of operation of these
the most operators.
╔═════════════ ═══════════════════════════╗
║ AND s Bitwise logical <>. ║
╚═════════════ ═══════════════════════════╝
The symbol s denotes the operands A, B, C, D, E,
H,L,n,(HL),(IX+d),(IY+d).
In general, this command executes a binary
operation i.e. the operation is carried out on
two numbers. Despite the fact that after
operator costs one operand we and
processor we mean command AND A,s
but since this operation is performed
exclusively above the battery then
The first operand is not required. How
as can be seen from the name of the operation besides
all of the above and
bit t. e. operation <>
is performed on individual bits
battery. This operation is also
called binary multiplication i.e.
0 and 0 = 0 x 0 = 0
0 and 1 = 0 x 1 = 0
1 and 0 = 1 x 0 = 0
1 and 1 = 1 x 1 = 1
For final understanding, I will give
example: 37 and 58
37 = %00100101 so even though this is
and multiplication but
58 = %00111010 37 and 58 <> 37 x 58
------------------ you can only multiply
32 = %00100000 to binary units.
Well, and most importantly: why the f**k is this necessary.
1) Checking the battery for zero.
You're sitting there coding and suddenly you like
I'm dying to know what's in your battery
lying around and don’t spoil it when checking
I compared it with zero and that’s it: CP 0 and that’s it
satisfied. Everyone except PIXel or me.
After all, the enta command takes up two whole bytes
and wasting memory is unacceptable
pleasure for the conscientious coder,
such as PIXel (and I'm also modest :) )
This is where the command AND A was needed.
t. e. we are here "AND'im" the battery itself c
itself => its value does not change (1х1=1
0х0=0) but the command also affects the zero flag
sets it only in case of null
battery
2) Reset required bits.
Well, it’s time for you to reset bits 2, 3, 6.
RES 2,A
RES 3,A
RES 6,A
of course it’s also good, but again it takes up
a lot of memory and perhaps slows down, so I
I recommend AND %1010011.
Why the hell should I reset bits - you say
And I’ll say - How the hell? a remainder of
divisions by 2, 4, 8, 16, 32, 64 or 128.
Suppose division by 8 may remain
number from 0 to 7, aexactly the least significant 3 bits
i.e., leave bits 0, 1, and 2, and the rest
we reset the bits. Does all these things
command AND 7 or AND %00000111.
3) Well, probably something can be done
but I don’t remember this anymore!
╔═════════════ ═══════════════════════════╗
║ OR s Bitwise logical <> ║
╚═════════════ ═══════════════════════════╝
Well, here with the words “bitwise” and
"logical" is the same story. Logic
next: 0 or 0 = 0
0 or 1 = 1
1 or 0 = 1
1 or 1 = 1
Application:
1) Setting bits.
OR %00000111
The command sets the three least significant bits,
the remaining bits are unchanged.
2) Check forbattery zero.
Same story as with the AED.
3) Checking for a pair to be zero.
Acceptable after each case reduction
BC we need to check it for zero, so
as the DEC BC command to the zero flag is not
influences, you will have to check with others
ways. The vast majority of
In my opinion they do it like this:
LOOP ...
DEC B.C.
LD A,C
OR B; !!!!
JR NZ,LOOP
...
It is logical to assume that BC is equal to 0 only
in case registers B and C are equal to zero
at the same time. because only 0 or 0 = 0
a everything else (other cases or'a)
equals one, then B or C gives zero only
in case B=C=0 => BC=0.
╔═════════════ ═══════════════════════════╗
║ XOR s Bitwise exclusive <>║
╚════════════════════ ════════════════════╝
This is the same OR only combination
1 hog 1 = 0.
Application:
1) Resetting the battery.
LD A,0
occupies 2 (two) bytes, therefore reset to zero
you need the following commands:
SUB A
A number subtracted from itself gives zero.
OR 0
Turn off all bits => A=%00000000=#00=0
XOR A
0 chorus 0 = 0 , 1 chorus 1 =0 => A=0
any of these three commands resets
battery.
2) Inverting a number.
XOR #FF = CPL
1 hog 1 = 0, 0 hog 1 = 1
=> all bits of the number are inverted.
3) Comparison of the number s with the accumulator.
AND sThe battery is reset if A=S and
the zero flag is set.
------------------------------------------
Comparison and multiple mathematics.
CP s
The command is executed similarly to the command
SUB s, but the result of the subtraction is not written -
exists, but only in accordance with it
The bits of the flag register are changed.
Results of comparison of operands.
┌-----------┬---------┬------------------┐
│ Result │State│ Mnemonic │
│ comparisons │ flags │transition conditions │
├-----------┼---------┼------------------┤
│ A = s │ Z = 1 │ Z │
├-----------┼---------┼------------------┤
│ A <> s │ Z = 0 │ NZ │
├-----------┴---------┴------------------┤
│ Unsigned comparison (range │
│ representation of numbers 0... 255 ) │
├-----------┬---------┬------------------┤
│ A < s │ SU = 1 │ C │
├----------┼---------┼------------------┤
│ A ≥ s │ SU = 0 │ NC │
├-----------┴---------┴------------------┤
│ Comparison taking into account the sign (range │
│ representation of numbers -127... +127 ) │
├-----------┬---------┬------------------┤
│ A < s │ S = 1 │ р │
├-----------┼---------┼------------------┤
│ A≥ s │ S = 0 │ t │
└-----------┴---------┴------------------┘
Multiple mathematics.
In fact, I doubt the existence
introduction of such a definition as a multiple of mathematics
matuka, but that's what I decided to call it
operations with numbers that are multiples of 2 (two).
For a better understanding (and maybe more
why), let's figure it out (some may not
figured out) with number systems.
I'm not going to bore you with text from
paragraphs on matuke, I'll tell you how I know,
I can and understand this question myself.
Decimal system (DEC).
The decimal number system is
system ...enea with base 10.
1. The number consists of digits.
2. Digits, from least significant to most significant,
stands for units, tens, hundreds, ....
or the base to the 0th degree, basic. in 1_oi
degrees, basic to the 2nd degree, .....
accordingly. T. o. 2374=4+70+300+2000=
=4*10^0+7*10^1+3*10^2+2*10^3.
Hexadecimal system (HEX) has
base 16, abinary base 2. so o
number #ABCD=D*16^0+C*16^1+B*16^2+A*16^3,
where A..F = 10..15.
Shifts the digits of a number to the left by 1 digit c
by inserting zero into the least significant digit
is equivalent to multiplying this number by
bases of the number system in which
number presented! (y-a-a-y how
said). For example, shift the number 25
left from behind. . . .charge and we get 250.
Accordingly, shift -//- to the right
--//-- to high order --//-- divisions
this number by --//--. t.o. 123/10=012.
Well, my friend, as everyone knows,
diaper numbers in the computer are presented in doublein its original form =>
SLA s ; multiplication by 2.
SU <- 7<-s<-0 <- 0
SRL s ; division by 2.
0 -> 7->s->0 -> SU
SRA s ; division by 2 co sign.
7->s->0 -> SU
└----does not change.
etc.
------------------------------------------
Z.Y. I myself am surprised how I feel
They gave the Russian a 4_ku.
Z.Y.Y. People, write, call, ask
if something is not clear. If I do it myself
If you ask me an answer, I will definitely answer
everyone.
Share your thoughts about the article