Nicron #01
30 сентября 1996

Programming - a course of study assembler Wlodek Black.

<b>Programming</b> - a course of study assembler Wlodek Black.
 5. - The course of study assembler -


(C) WLODEK BLACK

Hello, dear users!
In the beginning I allow myself to express my sincere gratitude 
to the newspaper "NICRON" for the offer of cooperation.  We are 
talking about some correspondence courses on programming 
language "Assembler". Actually, I've suggested this as one of 
the options for my participation in such a steep undertaking.  
It's no secret that among us, dear colleagues, many well-known 
coders (which means programmers in assembly language). But how 
many more do not display talent! 

  No loss (and vice versa, praising ...) the role of 
"Inforkom"-a in the great cause assemblerizatsii (read their 
books!), suggesting you something that can be called a synopsis 
of lectures on the assembler. Y This synopsis is a couple of 
advantages over the books "Inforkom" as: it can be sent over 
the network and for him not to pay. But there is and 
disadvantage: it is focused on the computer "MSX", which, 
although and built on the same processor but differ as the 
plane of locomotive. I just did not have time to make 
adjustments! But I made them (So ​​I'll make that ... !...), 
especially as the Polytechnic I now could read assembler 
course, not only for the MSX, but for the Spectrum.




       000h.Vvedenie.ChTO CAN GIVE Mastering the assembler?


   Hello, dear user! At this stage it is assumed that you 
already are familiar with any high-level programming language, 
BASIC, for example. At the same time you probably seen a lot of 
computer games with great graphics and understand that this is 
not napishesh.Na BASIC BASIC, like any other high-level 
language, you can create only that the language allows. When 
programming in assembler and the codes will be available for 
all that enables the machine. Computer games provide an 
opportunity to "feel the difference" even unprofessional. 
Writing a program in a language the processor can help, even 
when high-level language provides the necessary tools, but the 
program is running slowly or too large. Programmer, who owns 
native language processor, much easier to cope with the 
problems of failures, software incompatibilities, need to adapt 
programs to their conditions, etc. Some importance and have 
questions "hacking" programs, "obessmerchivaniya" games against 
malicious (viruses). Finally, knowledge of the machine up and 
down gives with nothing comparable self-confidence, a sense of 
their usefulness society. All of the most powerful, most 
needed, the most sensational, yes and the most expensive 
software is written in assembly language, at least for an 8-bit 
machines. 

   CPU Z80, in addition to MSX-"wells" and "Daewoo", used
even in this super-popular PC as the Spectrum, and on
It is based on working telephone numbers avtoopredeliteli, PBX,
industrial robots, even children's toys. Z80 - the only 
8razryadny processor continues to grow at the present time: 
already established high-speed and sverhekonomichnye 
modification, and progress is not going to stop. Z80 - the only 
8-bit processor, the annual production volume is increasing. In 
Russia it is released under the name K1810VM80 and KR1858VM1 - 
normal and high-performance variants, respectively. 

001h. Hands with eight fingers, Art Nouveau on the PCB,
        1 +1 = 10 AND OTHER FUNNY THINGS.


   CPU Z80 - eight-bit. The basic unit of information
with which it works - bytes. Byte - 8 bits. Binary system is 
very simple. Each subsequent digit number over the previous 2 
times. 


128 64 32 16 8 4 2 1
 * * * * * * * *

bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0

For example: a binary 11001011 is equal to:


  1 1 0 0 1 0 1 1

 128 + 64 + 8 + 2 + 1

                            = 203.

The number of ones in the number 8 "Kolov" equal 255.Takim
, the range of byte ranges from 0 to 255. With the 255 you 
could meet in the games, "trampled" crackers - for example, to 
255 and can be reduced the number of lives, cartridges, etc.


  Binary representation of numbers in most cases not very 
convenient - it is cumbersome, and not too prominently, a chain 
of ones and zeros melteshaschy merge into a pattern, in which a 
person can easily get confused and make mistakes. Therefore, 
people came up with a more suitable record of binary numbers - 
hexadecimal form. When byte in hex it is conventionally divided 
into two nibbles of 4 bits each (in foreign literature can be 
found discordant called "Nibble", in Russian same language use 
the term "notebook" or just say "nibble"), each of which is 
denoted by one symbol - the numbers from 0 to 9, and then the 
letter A, B, C, D, E or F. 

   A two-byte integer that represents a single unit, called the 
word. Word contains 16 bits. In hexadecimal it is written by 
four characters. 

   In MSX-BASIC you have already encountered the hexadecimal 
notation of numbers - for example, 'hF37D. In assembler, this 
entry appears slightly differently: the number must necessarily 
begin with a digit, so a hex-number, starting with the letter, 
attributed to the beginning of 0, and the letter "h" 
(hexadecimal - hex) put at the end - 0F37DH.


  There are derived units - kilobytes, megabytes, gigabytes.
Kilobyte - is 1024 bytes. Megabyte - 1024 kilobytes. And so on. 
Factor in 1024 was chosen instead of 1000 for two reasons: 
first, 1024 in binary notation - a round number (10000000000; 
in hex - 0400h); secondly, 1024 is close to the way a human 
tysyache.Hodit joke: a novice programmer a kilobyte 1000 bytes, 
and the experienced - a kilometer 1024 meters. 

   It is easy to calculate the value of two-byte words: maximum
it is equal to 65535 (0FFFFH).

   Now imagine that situation. From zero bytes, we subtracted
unit. How much do you get? Imagine a tape counter footage tape. 
What happens if you make one revolution counter back? Get 999. 
At the same time 999 - a 0 - 1. Became be, 999 =- 1. If the 
counter has 8 bits and thus only one unit per revolution, then 
one turn back from the position would give 00000000 11111111, 
ie 11111111 =- 1. Here we learned how to appear in binary form 
negative numbers: Senior, 7 th, the bit can be used as an 
indication of the sign - If it is 1, then the number - 
negative. If we continue twist our counter back, making 128 
revolutions reach value of 10000000 (binary). This - the limit 
for the negative numbers on the basis of one byte. In decimal 
it is equal to -128. Towards positive values ​​limit is 
01111111 binary, or 127 decimal. For the word range - from 
-32768 to 32767.


   If our counter was 00000001, then adding to it a
(Committing a turnover in advance), we get 00000010. Here goes,
that 1 +1 = 10.

   Thus, the finding in the memory byte 0FFH, we can assume 
that it's either 255, or -1. So how do you distinguish one from 
another? The answer may seem surprising: no. Truth emerge only 
when the byte will be used processor when performing any 
komandy.Dlya each team there its hard and fast rule, as 
interpreted byte of data - either as 8razryadnoe unsigned 
integer (0 ... 255), or as a 7-bit with sign (-128 ... 127).


  The word sign is a senior, 15, and bit.

  Bytes and words, we need at every step. Bytes - the main
unit for arithmetic and logical operations processor computer 
memory also has a byte-oriented. Word - the main unit for 
memory addressing. Z80 can be directly address 64K of memory. 
This is 65,536 cells, each of which is stored a byte. 16-bit 
address bus and 8-bit data - the cornerstones of the processor 
architecture. Architecture same computer, MSX-2 Complex - his 
memory is more than 64K, and since the processor at the same 
time is able to address only 64K of RAM computer has to be 
divided into pages, toggle a certain way. 


[End of 1 st Text].

                                             (C) Wlodek Black.

                                          Tel. (095) 462-8902

                                               Vladimir.






Other articles:

Entry - table of contents, preface.

Humor - anecdotes.

Games - Cheat, break open UFO II.

Graphics - kartinka ANSI graphics.

Programming - a course of study assembler Wlodek Black.

Advertising - advertising and announcements.

Epilogue - Finally, and contact the publisher.


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

Similar articles:
Introduction - The joyful news.
Version - 2 versions of the game: DIZZY Y.
Entry - As promised, was replaced by the shell, and hence and newspapers have had their face.

В этот день...   3 May