ZX Format #01
31 октября 1995

Programmers - Assembler: Assembler for Dummies

<b>Programmers</b> - Assembler: Assembler for Dummies
Assembler in Pictures

  for Dummies "and not only.


      Author: Michael Spitsyn.
________________________________


   We are starting a series of articles on
assembler for beginners with
to encourage people to study
this language.

   In these articles we Tell about
structure of computer graphics,
sound (48 and 128) and, naturally,
about the assembly.

   So ...


     1.PROTSESSOR COMPUTER


   As a person, and every computer has a brain, this brain
the computer is the processor.

   And what of the "brain" in our
Speccy?

  "Brain" Spectrum - a Z80 processor company ZILOG. Z80 CPU is 
псевдошестнадцатиразрядным. What does it mean? 

   The fact that each processor can understand the numbers
certain discharge. For example eight-number is written as a 
combination of eight binary ones and zeros

and may designate any whole
number from 0 to 255.

   Each digit of this number,
a power of two, for example
binary number 01100110 corresponds to the decimal 102, and
convert from decimal to binary can be as follows:

2 ^ 7 * 0 +2 ^ 6 * 1 +2 ^ 5 * 1 +2 ^ 4 * 0 +2 ^ 3 * 0 +
2 ^ 2 * 1 +2 ^ 1 * 1 +2 ^ 0 * 0 = 102


   Continue. Z80 has twenty
eight-registers (the register of a cell inside the processor, 
where you can record the numbers) and all registers are 
combined in pairs, each of which have

said: "register pair.

   So we got to answer
our question - 8 +8 = 16, so register pair gives
hexadecimal number.

   Now why Speccy
not just Hexadecimal,
and "pseudo" is.

   So we need to register
In order to perform on them
arithmetic operations, namely addition and subtracting. 
Unfortunately our little Speccy not able to divide and 
multiply, and so no about any more "scary" activities and can 
not speak. 

   So, Processor can add / subtract as registers,
and register pairs, ie perform arithmetic operations
over eight and hexadecimal numbers, as well as registers
are only eight bits (a
you are not IBM), then the processor
"Псевдошестнадцатиразрядный.


  Here is a table of all the registers
their purpose:


The main purpose of the register

 A 8-th battery
 F a flag register
 B 8-th counter
 BC 16th count
 DE register receiver
 HL 16th Battery
 Index register IX
 IY System Index
 I interrupt vector
 Register R regeneration
 SP top of the stack
 PC Program Counter

 Note:

  8 th - eight-



     2.PROSTEYSHIE TEAMS


   Now consider the simplest
assembly operations, using
As an example, BASIC, with whom, I hope you are familiar with.

   The first thing to do for
study the assembly - is to choose a "shell-assembler"
in which you work.

   Can you advise TASM128
if you ZX128 or for ZX48,
ZEUS ASSEMBLER.


   So begin:


    BASIC ASSEMBLER

  10 LET A = 1 LD A, 1

  20 STOP RET


   The command "LET" is equivalent to
command "LD", if you type
and run it, then register "A"
will be entered one. On command "RET" will exit in
calling program (if the program was launched in BASIC,
then the command "RET" it returns
Management BASIC'u).

   In all registers, except for "F" and "PC", you can enter
numbers, such as:


    LD A, 1, 1 -> A

    LD B, 15, 15 -> B

    LD HL, 16384, 16384 -> HL

    LD IX, 50000; 50000 -> IX


   But usually, the programmer does not
lack of registers, then we have to use your computer's memory, 
for example: 


    BASIC ASSEMBLER
LET A = PEEK 23556 LD A, (23556)


   After executing this command
in the "A" will be a number,
recorded in a given memory cell, and given that in this
cell BASIC code stores the last key pressed, this command is 
not devoid of practical sense.


   Also used reverse
Team:


    BASIC ASSEMBLER
 POKE 23607, A LD (23607), A


   But often have to write / read the value of the cell,
address of which calculated
or taken from the table. In this
If we use the following
Team:


   Write read

  LD (BC), A LD A, (BC)

  LD (DE), A LD A, (DE)

  LD (HL), 0 LD E, (HL)


   Note: I would like to see
 that non-existent commands the direct recording of the cell 
parameter cards, an as recording from a cell  in a cell.



   And now I want to lead a program that prints any
message (it is analogous to the operator to "PRINT").

   The program uses the command "CALL", to invoke a procedure 
ROM, this command can be compared with the BASIC command

"GO SUB", for example:


     BASIC ASSEMBLER

  10 GO SUB 999 CALL M1

      .... ....
 999 LET A = 1 M1 LD A, 1
1000 RETURN RET


   Here, "M1" is a label, instead of
which in assembly
program will be delivered the appropriate address.


       EXAMPLE PROGRAM


   After the semicolon in the assembly, as well as after REM
in BASIC written comments.

 ; Program print text
 ; Messages. -= PRINT TEXT =
      ORG 30000

      ENT
START LD A, 1, 1 Open

      CALL # 1601; Feed

                ; Print.

      LD DE, TEXT; Address Text

      LD BC, LEN; Text Length

      CALL # 203C; Print Text

      RET
TEXT DEFB 22; code "AT"

      DEFB Y, X; Position Print

      DEFM "HELLO, EVEREBODY!"
LEN EQU 20; LEN = 20
Y EQU 10; Y = 10
X EQU 5; X = 5


   This program is similar to
line BASIC'a:
 1910 PRINT AT 10,5; "HELLO,

    EVEREBODY! "



   In the next issue I will discuss
of arithmetic instructions and commands, comparison, and an 
example of a small game. 


   Bye!

________________________________





Other articles:

IS-DOS - Information: The news in the world IS-DOS

IS-DOS - a beginner: IS-DOS - the first acquaintance

IS-DOS - users: A short guide on system drive IS-DOS

IS-DOS - Programmers: UniColor - Standard color settings in the programs of IS-DOS

IS-DOS - programmers: Window System IS-DOS

IS-DOS - Programmers: Program gmen.com

Iron - Revised:-lock to port # 1FFD on Scorpion ZS-256

Iron - The provinces of: brake KAY'ya

Iron - Manufacturer: KAY

Iron - Manufacturers: Scorpion ZS 256

Toys - Novella: Crystal Kingdom Dizzy

Toys - on the shelves: Bulls and Cows

Toys - on the shelves: a UFO. Enemy Unknown

Toys - What's New: Overview of new products

Interview - Old friends: A Story of Glory Mednonogova on its activities as a programmer

Information - From the authors

Contest - Competition for the Competition

Contest - Levels of Laser Squad

a rest - Something: one day in the life of a programmer

Mailbox - Classified Ad

Mailbox - Exchange of experiences: Cheats

Mailbox - Letters Game

Premiere - Color Lines

Programmers - Basic for All: Basic programmers

Programmers - Assembler: Assembler for Dummies

Programmers - Systems: Editor missions to the game Laser Squad

Miscellaneous - Amiga: Amiga History

Miscellaneous - Outlook: Toy


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Demo Party - the results of Chaos Construction 999.
System - Personal computer ATM Turbo 2 +: Technical Description and Programmer's Guide: Hardware error fee. The problem of PC-XT keyboard. Connecting the hard drive (IDE). Bug of the RAM-DISK'a.
Hall of Fame - determination made in the demoscene and Spectrum.

В этот день...   28 April