+======================================================+
| Coding... |
+=====================================================+|
X-treamer/Infotek +=+||
+=++|
Section for beginner coders.. +=+
So, with this issue we will start the review
Z80 processor commands. First section -
These are 8 and 16-bit boot commands.
The Z80 processor permanently stores
working form the following registers:
BC - register counters;
DE - bit registers;
HL - address registers;
A - battery - all main
arithmetic operations are performed with
him;
F - flag register, inaccessible
in its usual form;
SP - stack address pointer;
PC - current position indicator used
fullness;
IX,IY - index registers;-----------------------------------------
Now let's start describing the commands
CPU 8-bit boot:
LD A,B - downloads the contents of the re-
register B to register A. This is abbreviated
denoted as A-------------------------------------------------------
Next, let's look at 16-bit commands
downloads:
the command also has the format LD dd,nn, where
dd is one of the registers:
BC, DE, HL, SP, IY, IX - double-half
registers. Please note that it is not possible here
assign register to register. You can
only directly enter values into the register
WORD type.
Working with memory cells is carried out
Available with both 8-bit and 16-bit
in-line:
LD (nn),A - approximately means that in
memory cell with address nn is entered according to
battery holding. Those. value re-
The letter or number in brackets means the address
memory cells. It might also benext
assembly mnemonic entry:
ld de,49152
ld (de),a
This means that the memory cell is ad-
Resu 49152 (#С000) contents are entered
battery
Writing to memory cells can be
16-bit, for example:
ld de,49152
ld(de),32768;
Directly specify addresses in brackets or in
In either case it is impossible.
Reading from a memory cell can be
also 8 and 16-bit:
ld de,49152;
ld a,(de) - cell contents by
the address specified in DE is entered into the account
cumulator Also,
ld de,49152;
ld hl,(de);
means that the contents of two cells are
addresses 49152 and 49153 are converted to
number of word type and entered into a pair of re-
histrov hl.
-----------------------------------------
We will not touch upon index re-
hystra and move on to the description of 8 and 16-times
series arithmetic. Arithmetic/logical
Some Z80 device (ALU) can be stored
add and subtract registers, as well as their
increment and decrement, inUnlike Intel (outside;),which can
only fold (that's why he
Supermazdie). Basically all logical
operations and comparison operations work with
battery. Let's start with the operation
incrementing and decrementing re-
gistrov: commands such as inc rr and dec
rr, where rr is any register or pair of re-
hystrov literally mean the following:
inc rr - rr=rr+1 , and
dec rr - rr=rr-1.
In fact, these commands, working with 8 times-
row registers take 4 clock cycles, and with
16-bit - 11 clock cycles, while
direct addition operation will take 7
and 15 cycles respectively.
Add A,r command - the command adds to
the accumulator contains the contents of register r and is
is based on 8-bit arithmetic. Team
add a,n adds the number n to register a.
sub n - command to subtract the number n from ac-
cumulator. It is only present in
8-bit arithmetic. in 16-bit
arithmetic does not work directly with numbers
- there is only register arithmetic -
mi, for example: add rr,dd, where rr and dd are
16-bit registers. And, for example, to
you need to add the number 80 to the HL register
do the following:
ld de,80
add hl,de. There are also incremental commands
formation and decrementation, such as:
inc rr, dec rr.
When performing arithmetic operations, use -
The following flags are available: P/V.
V - sign of result overflow
arithmetic - this flag is turned on if the
The result in an 8-bit register is greater than 255
or in a 16-bit register greater than 65535.
Or the register value is less than 0.
P - flag is a sign of parity of the result -
ta.
------------------------------------------
Logic and working with conditions:
The Z80 processor contains logic commands
type of byte or register overlay by OR,
AND and XOR. Yes,
Xor rr, or rr and and rr means that
the number or register rr is combined with the accu-
mulator as a result of logical operation
tions. The P flag is also used here -
parity sign.
The operation of comparing an accumulator with a number
is done with the command CP n, where n is any
bo number. The result of this command
presented in the following table:
+--------------+-----------------------+
| Result | flag mnemonic. |
+==============+=======================+
|A=n | Z - 1 |
| A<>n | NZ - 0 |
| A>n | C - 1 |
| Aret, there are conditional call commands,
executable relative to flags:
Call NZ, nn - calls the procedure according to ad-
Resu nn if flag Z contains 0. Reverse
procedure - Call Z,nn. There are also commands
Lovely unconditional =) transition:
JR nz,nn and JR z,nn - relocatable co-
mands and JP nz,nn and JP z,nn - non-relocated
unconditional jump commands.
-----------------------------------------
In the next issue we will look at the work
with commands for moving memory blocks into
another memory area and to the port. Teams
rotation, checking and installing/resetting bi-
Comrade In the meantime, deal with these team-
mi.
-----------------------------------------
Let's move on to a new effect. Or rather the effect
not new, I will give you a new modification because
known procedure that will help you
develop new effects like
256-color:
NumDB #17
ld a,(num);
xor 8
ld bc,#7FFD
out(c),a
ld(num),a
ret
This procedure can be suspended intermittently
vania and it will forever blink with two indicators
wounds.
Share your thoughts about the article