IS-DOS assembler - the basics of programming in assembler for beginners and programming for IS-DOS.

Возраждение #1
This section can fairly be divided
into two parts.  The first part will be for
starting their journey into the world of programming language
roving 'assembler'. The second part for already
who managed to thoroughly study the latter,
but those who have not mastered it completely or completely
owing complexity in programming for
is-dos system.

  Many novice programmers, when studying
learning assembler, they come to a row of rising-
questions before them, which require
it takes a lot of time to work with them
get together  After all, we all think differently,
and the difference in thinking of a beginning programmer
A mister and a professional are very different.
The authors of the most interesting articles on
The assembler is also unable to pre-
see all possible questions that
may occur to the user, and related
Not everyone has the opportunity to work with them.
Therefore, we will consider everything that
the reader would like to know about this topic,
All you have to do is write to us at
specified in the advertising section.
  And so today we will start from the very basics,
i.e. from possible number systems
in the computer. Here we will look at three vi-
yes: decimal, binary and hexadecimal
ric number system (there is also
also octal).

  Are you familiar with decimal numbers?
0,1,2,3,..,9,10,11,..,19,20,21,... etc.
As you can see, their name comes from
that all these numbers involve digits
from 0 to 9, there are just themten.

  Binary digits. You got it right they
consist of only two digits 0 and 1, for example
measures 0,1,10,11,100,101,111,1000, etc. How
comparing them with decimals is very simple.

 Decimal Binary
      0 0
      1 1
      2 10
      3 11
      4 100
      5 101
 etc.

  In assembler they are denoted by the sign
'%', i.e. when we write %10010011, then
we mean the number 147 decimal. you
ask, how does this apply to the computer?
The fact is that each memory cell
(byte) can take values from
0 to 255 or %00000000 - %11111111. This
clearly visible if you spend in basic
experiment: poke 16384, .
If you did this, you saw that all
picture with pixels (dots on the screen)
very similar to binary code. Included-
the corresponding pixel is 1, and off -
mu 0. Now let's think about how it's easier
draw a picture by writing down ten
tic number or binary where visible to us
every pixel. By the way, don’t try to
to write the binary form of a number in basic, he
too old and uneducated. If in the screen
This area has the name pixel then in the ra-
In memory, this is called a bit. Layout
here it is:

              Number 0..255.
┌────┬────┬────┬──── ┬────┬────┬────┬────┐
│7bit│бbit│Sbit│Хbit│Зbit│2bit│1bit│Obit│
└────┴────┴────┴──── ┴────┴────┴────┴────┘

  If the bit is on then there1, off 0.
Example:
%10000000 = 128
7bit is on, the rest are off.

  Is it too simple? We agree with you
binary code is too simple, which
Many numbers can get confusing, decimal
or inconvenient. There is a way out, it’s sixteen-
ary code or numbers (no difference).
  Where can I get six more numbers, you ask?
The solution is found if you take additional
numbers from the Latin alphabet A, B, C, D, E, F.
Now we have everything we need.  But what about
will this look like in reality?

Decimal Binary Hexadecimal
    0 %0000 0
    1 %0001 1
    2 %0010 2
    3 %0011 3
    4 %0100 4
    5 %0101 5
    6 %0110 6
    7 %0111 7
    8%1000 8
    9%1001 9
   10%1010 A
   11%1011B
   12%1100 C
   13%1101 D
   14%1110 E
   15%1111 F

  It turned out to be an interesting pattern.
%1111 = F then %11111111 = FF.  So one
a byte can be represented with less than eight digits -
mi as binary code, and not three as in
decimal, but only two.

Example:
255=%11111111=FF

  There is one thing, so that the computer does not confuse
decimal with hexadecimal is special
cial '#' (#7C), or another 'h'
(7Ch), but here you need to specify if the number
starts with the letter then inplaced in front
else and zero (OACh), this is only for 'h'.  And
IS-ASSMBLER, GENS, ZEUS still do not understand
this letter, but TASM and all assemblers
on cooler cars they will understand both
goe.  Maybe hexadecimal numbers and
seems to you a difficult number system,
but remember when you learned to read, you
it all seemed too clever too.  A
Now it doesn't even bother you. But I love
in any case in assembler without this icon
'#' has nothing to do.  Or you will have to
break programs with binary code, which
will make it difficult to read for you
yourself, so don’t neglect it
How do you not neglect letters when reading?

  Now you are ready to enter into a wonderful
the world of assembly language programming.
You can always negotiate with the computer
in his native language, whatever the task
stood in front of you. Well let's begin.


      DATA REGISTERS AND BATTERY
      ═════════════════════════════

  In the Z-80 microprocessor, which controls
If your computer has special
cells where temporary numbers with co-
who you work with and where they undergo-
have their own changes.  Let's call the cells a word
register All calculations and data transfer
work only through registers.  What would
to add two numbers you need to place them first
them into registers and then add them, and
the result will be in one of the registers. Here
they are A,B,C,D,E,H,L,F. In each of these registries
tre maybeis a number from 0 to 255.
Moreover, B and C, D and E, H and L, can combine
seems to indicate an expansion of the range
used numbers from 0 to 65535. They are written
they are BC, DE, HL.  But that's not all there is yet
alternative set (spare), A', B',
C', D', E', H', L', F', they are designated as such
are indicated by a dash after the letter.  Processor
can only work with one group of re-
hysters either with the main or with alter-
native.  There are commands that switch from
one set to another, and alternative
tives become basic (without '), and
main alternatives (with '). Determine
It is impossible to determine which set is included.
  There are registers already doubled and divided
it is not possible for them to be IX, IY.

  Register "A" is the most important, it is called
accumulator, when calculating mainly
the result is placed there.

  Register "F" is not the most interesting there
keep the numbers but look at what happened when
calculation.  Here is the whole schedule only for
bit.

           ┌─┬─┬─┬─┬─┬───┬─┬─┐
           │S│Z│x│H│x│P/V│N│C│
           └─┴─┴─┴─┴─┴───┴─┴─┘
            7 6 5 4 3 2 1 0

  Each individual bit in it is called
flag. Flag set = 1, flag cleared
= 0.

  Z(zero)-zero flag. Set if
the result of the operation is zero.

  P/V(parity/overflow) - parity flag
replenishment  In logical operations, established
is poured when the parity of the res-
ltata, in arithmetic - when overfilled
research institute(the number is greater than 127, i.e. 7bit is included)
chen).

  CY(carry) - carry flag. Installs-
if, when performing arithmetic operations,
erations, i.e. the number turned out to be greater or
less than will fit into the register.

  S(sing) - subtraction flag. Installed
if the previous command was subtraction.

  The remaining flags are designed for internal
processor operation. And use them
mining


             COMMAND COUNTER
             ══════════════

  When executing the next command, the processor
must know where to get the next one.
This is monitored by a 16-bit co-counter.
mand register PC.  He can accept knowledge
values from 0 to 65535. Therefore, the Z-80 can
understand only these addresses in your work
and not one more address, in computers
128k and more are still the same, but there is
alternate memory pages that
can be replaced with the main ones, so only
manages to fool the processor.


             STACK INDEX
             ═══════════════

  16-bit PC stack pointer register
additional opportunity for programmer
ta. This is a specially installed user-
the user part of the RAM, pre-
designated for temporary storage of data
nykh.  The stack is organized on a first come first served basis.
entered, last to leave. With every recording
the PC register is decremented by 2. When taking
data back increases by 2. Re-
The PC gistr shows the address where the
The stack is stacked.  Communicating with the Stackis happening
only with register pairs.


             OTHER REGISTERS
             ═══════════════

  Interrupt vector register I, using
It is in the second interrupt mode.  Him we
Let's look at it when we deal with the interruptions themselves.
yami.
  Dynamic Memory Regeneration Register
R, caters to hardware needs
processor and changes unpredictably
(not entirely correct).  Used for
writing random number procedures. Sta-
the first digit is not used in hardware,
note this, rarely does anyone use it,
probably programmers in a hurry to study
assemblers did not attach any importance to this.

  With this we will focus on the topic for...
starting until the next issue of the magazine.  And
let's continue for those who are already practically
used machine programming
code.

  You've probably tried more than once to use
call translators as.com and link.com.
If someone did not succeed, then we
we'll tell you.  
  First, the program must be typed
in the text editor is-edit and have ra-
'as' extension. Then the bat file is written to
who will broadcast the program to the public
project code.  It can be made even easier for you
the file extent.txt is known, so here you go
there is a line:

as :Q:IS-ASSMASMas /+l /+t /cut

  Now any file can be streamed
just press the [ENTER] key.
If suddenly you do not understand the meaning of the keys
then look at help as.com. Please note that but-
new file withextension 'obg' is not ready yet
to launch because didn't go through the linker.

  With link.com it is more difficult here if you want
create a executable file that produces
is applied to your library (to files produced
that perform some functions needed by the program,
but this text was not included in the program itself,
the program accesses them like CALL $<
procedure name>), then you should create
bat file indicating the names of all not included
our procedures.

Example:
 demo.obg - main program;
 $string.obg - creeping line procedure;
 $cls.obg - original cleaning procedure
                                  screen;
(all files in the same directory with the bat file)

  Here the bat file will be like this:

Q:IS-ASSMASMlink_/_
demo_string_cls

_ is a space (the line did not fit).
  All text is on just one line.

  We hope the operating principle is clear, and the key
You will find information at help link.com
etc.
  Now some procedures that
can in your difficult work. First of all-
th we will publish logic procedures, comparing
understanding of 16-bit numbers.  These procedures we
used to make a magazine and
they served us to calculate the beginning /
end of the text.

1.Compare HL>DE
 (input:HL-1st number);
 (DE-2nd number);
 (output: flag C=1-error);

$OPB LD A,D ;compare older
       CP H ;bytes.
       JR C,OPB2 ;if H>D (true)
                      ;go topro-
                      ;exit procedure
                      ;but.
       JR NZ,OPB1 ;if H is not equal to D
                      ;then the transition is not correct
                      ;but.
       LD A,E ;compare low
       CP L ;bytes.
       JR C,OPB2 ;L>E, that's right.
OPB1 SCF ;set flag C
       RET ;because HL>DE not ver-
                      ;but.
OPB2 XOR A; reset flag C t.
       RET ;k. HL>DE.

2.Compare HL=DE
 (input:HL-1st number);
 (DE-2e number);(output: flag C=1-error);
$OPBR LD A,D ;compare the highest ones
       CP H ;bytes.
       JR C,OPBR1 ;H>D - no error.
       LD A,H ; compare again
       CP D ;high bytes.
       RET C ;H does not equal D-error
       LD A,L ; compare the lower ones
       CP E ;bytes.
       RET C ;L
															

Share your thoughts about the article