+++++++++++++++++++++++++++++++++++++++++++
Section: Programming
Basics of programming in ASM.
This section is intended for the youngest
i.e. novice coders, ever-blooming and
our beloved SPECCY platform.
So, let's begin our conversation.
In case you don’t know, then I’ll give you a ha-
Characteristics of the registers of the Z-80 processor.
+ can be used one at a time.
* only as a registered couple.
= only as one register.
A - battery. Main register for Z-80.
Most logical and arithmetic
operations are performed by using
battery (=)
HL is one of three register pairs. Is-
is the most important of them. There are a number
arithmetic operations with HL. (+)
DE - mainly used for storage
16-bit number or address. (+)
BC - same as in DE. Register B is used
acts as a cycle counter. (+)
SP - stack pointer. Used as a me-
hundred saving return addresses, but can
be used as a workspace. Ra-
works according to the principle: last to come, first
you left. (*)
I - interrupt vector register. Use-
is entered to place device addresses.
yes-conclusion. (=)
R - memory regeneration register. He reveals-
with a simple counter that increases
every time you perform a regeneration cycle
walkie-talkies. The value in the register is cyclically inter-
Ranges from 0 to 255. (=)
IX,IY - used to perform operations
tions,which includes working with a table
data. You can use halves of these
reg.pairs, although the literature is silent about this
et.
F - flag register. For a programmer, well-
Only 4 flags are needed. This is the zero flag, flag
sign, carry flag and parity-carry flag
fullness. (The flag corresponds to one bit
register F.)
Also, the Z80 processor has a set of alter-
native registers that are included together
pussy EXX. They are designated A', F', etc.
Determine which of the sets is used in
is currently impossible.
Now let's deal with the problem of choosing an editor
torus of assembly texts.
Nowadays it has already been written many times -
great editors and each of them deserves
special attention. Their main feature is
Personalities are conveniences. For example, I write in ZX
TURBOASSEMBLER v3.0. Sometimes in XAS and MASM.
By the way, the ideal assembler is still
not written :-( (my point of view)
Let's move directly to the examples:
(since this is the first number of FANTOM, then we use
walkers are not very cool :-(
;print sprite
;INPUT:DE-ADDRESS OF SPRITE
; HL-COORDINATES in familiar places
; B-WIDTH
; C-HEIGHT
LD A,H ;calculate the address by
AND #07 ;to the specified coordinates
RRCA ;in HL.
RRCA
RRCA
OR L
LD L,A
LD A,H
AND #18
OR#40
LD H,A
LOOP PUSH BC
PUSH HL
LOOP1 LD A,(DE) ;display cycle.
LD(HL),AINC DE
INC L
DJNZ LOOP1
POP HL
POP B.C.
CALL DOWN
DEC C
JP NZ,LOOP
RET
;GO TO THE NEXT LINE IN THE SCREEN.
;ADDRESS IS IN HL
DOWN INC H
LD A,H
AND 7
RET NZ
LD A,L
ADD A,32
LD L,A
RET C
LD A,H
SUB 8
LD H,A
RET
As you can see, nothing complicated...
Let's move on...
KEY SURVEY
If you need to poll a key or not
how many keys, then the program that will
this will look something like this:
this way:
(questioning the ENTER key)
LD A,#BF
IN A,(#FE)
BIT 0.A
JP NZ,ENTER
Below I give you a list of keys and ports to
him.
╔═══╦═════════════════╦═══════╗
║BIT║ 4 3 2 1 0 ║ PORT ║░
╠═══╩═════════════════╬═══════╣░
║ V C X Z CS ║#FE,254║░
║ G F D S A ║#FD,253║░
║ T R E W Q ║#FB,251║░
║ 5 4 3 2 1 ║#F7,247║░
║ 6 7 8 9 0 ║#EF,239║░
║ Y U I O P ║#DF,223║░
║ H J K L ENT ║#BF,191║░
║ B N M SS SP ║#7F,127║░
╚═════════════════════╩═══════╝░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
PRINTING SYMBOL 8x8
; INPUT:A-SYMBOL CODE
; DE COORDINATES ON SCREEN
; FONT ADDRESS FONT-256
LD L,A
LD H,0
ADD HL,HL
ADD HL,HLADD HL,HL
LD BC,FONT
ADD HL,BC
LD A,D
AND 7
RRCA
RRCA
RRCA
OR E
LD E,A
LD A,D
AND 24
OR 64
LD D,A
LD B,8
LOOP LD A,(HL)
LD(DE),A
INC D
INC HL
DJNZ LOOP
RET
Its execution speed is average.
WORKING WITH TR-DOS
If you need to read or write to
disk group of sectors, then this can be done
like this: in HL we place it where or from where it is needed
will read, in D - the starting track, in E
starting sector, in B - the number of sects
rov for recording or loading, and in the C code fu-
Functions (6-write, 5-read). After this-
Then we disable interrupts and do:
CALL #3D13
enable interrupts and return.
Well, that's all for now. In the next issue
we must ;-)
Share your thoughts about the article