Polesse #06
19 мая 1999

Assembler - The structure of the screen.

<b>Assembler</b> - The structure of the screen.
                  ASSEMBLER FOR BEGINNERS


(C) THINKER



   Hello to all those who are still trying to learn how to 
create their programs in assembly language. It has long been in 
our paper was not this column, what is my fault and all of our 
favorite ministry education, but I promise today to pay for 
everything. Ready? Let's go! 


   As you've probably figured out, if not to abandon the Basic
then your program will work like a "Windows" on
286-m IBM processor. In order to get rid of the bonds the Basic
need to work directly with the screen, which you need to know it
structure and the structure of his tough! The screen is divided 
into 3 parts, Here is their address: 1 st - 16384 (# 4000), 2-I 
- 18432 (# 4800), 3rd - 20480 (# 5000). (Recall that the symbol 
"#" before the number means that the number translated into a 
hexadecimal system, and the symbol "%" means that the number in 
binary) So how does it address the RAM, we can send back a 
different value (remember that such 'LD'?). How could appear on 
the monitor of bytes that we put in area of ​​the screen? Very 
simple: as the number in the binary system, where 0 - off pixel 
(dot), and 1 - Included. For example, it is necessary to derive 
a point in the upper left corner of the screen. To start 
calculate the address of the screen: this is the beginning of 
the first third, then the address - 16384 (# 4000).



   Here's how it will look angle:


                     , Of pixels-off


                 That's what we need to send bytes to the 
screen: 

                                   =% 10000000 = 128

                              √

                         8 pixels


   Hence we need to send the number "128" at 16384 (# 4000)
then in the upper left corner will be the point. Here's 
programm in assembler, which reflects this: 


                        LD A, 128

                        LD (16384), A

                        RET


   Now do this:



                            = 01010101 = 85%



                        LD A, 85

                        LD (16384), A

                        RET


   I will say that usually in assembly language, you can write 
directly the binary number, without converting to decimal.


   Now how are the bytes in each third. Remember how loaded 
screens with a tape recorder? First, fill the top-most row of 
pixels, then begins to fill the by 8 pixels below, and so 8 
times, then filled in the second row of pixels and everything 
is repeated until the moment when the completed the first 
third, then repeat for all 2 nd and third. For Wow, to 
understand all of this, type the following program in BASIC, 
which fills the screen area value of 255: 


                    10 FOR F = 16384 TO 22528

                    20 POKE F, 255

                    1930 NEXT F


   As you've probably already noticed, before moving on
the first row of pixels on the second, vysheprevedennaya program
fill 256 bytes (ie 8 * 32). Hence, in order to find the address 
of the beginning of the 2-th row of pixels, it is necessary to 
16384 (# 4000) added 256. Just find the address of the 3rd, 4 
th ... 8 th. Here, as are the bytes in the screen:




  Address in the decimal system: In hexadecimal:


  16384 16385 16386 16387 16388 # 4000 # 4001 # 4002 # 4003 # 
4004 


  16640 16641 16642 16643 # 4100 # 4101 # 4102 # 4103


  16896 16897 16898 16899 # 4200 # 4201 # 4202 # 4203


  17152 17153 17154 # 4300 # 4301 # 4302



   Noticed a relationship in the right table? Take the address 
# 4001. This two-byte (shestnadtsatibitnoe) number that when 
entering into reg.paru, for example 'HL', as follows: first 
reg. will contain the value # 40 (in our case, H = # 40), and 
the second # 01 (L = # 01): 


                 LD HL, # 4001; H = # 40, L = # 01


   It is now clear: in order to move to the next line
pixels, it is necessary to add the current address 256 bytes or
which is the same, increase by 1 byte. However, this only works 
within one line of familiarity, that is, if you want to move to 
the symbol below by increasing the senior address byte, you 
have no success, and here's why: Suppose that we want to move 
from the zero symbol, the start address of which-16384 (# 4000) 
on the symbol below, it needs to move address screen in 8 pixel 
rows down: 16384 + 8 * 256 = 18432. Like all true, but look at 
the resulting number: it is is the second third of the screen, 
so we moved nA not a symbol, and at 8!


   Teper attributes. There are much simpler: the beginning - (# 
5800), structure is progressive. That is, if you fill the first 
32 familiarity color, then move on line below. When zasylanii 
values In the Attributes corresponding color-*- flicker

sponding familiarity varies as follows-√ √ √ √-brightness
follows: the ink is taken from 3-x 7 6543210-paper
The first bit (bit 0 .. 2), a paper from the ink
of bits 3 .. 5, brightness, and flicker
established in accordance with the 6 th and 7 th bit. Here 
trehbitnye values ​​of the numbers 0-7:



 0 -% 000 2 - 010 4% -% 100 6 -% 110 For example, we need to 
top 1 -% 001 3 - 011% 5 -% 101 7 - 111% it left a si            
                        nyuyu paper, yellow ink 

                                    (Original in itself), with 
the brightness and turned off by blinking. Yellow ink - 6% = 
110, blue paper - 1% = 001, flicker and brightness - of 1 and 0 
=% 10. Now the total of these pieces of a single byte:% 
10001110 =% 10001110 = 142. But the programm:



                        LD A, 142

                        LD (# 5800), A

                        RET


   As of today, probably enough. I leave you to digest
information received. And in the next issue, we will detail
acquainted with the most important commands in assembler.

   Until we meet again.







Other articles:

Assembler - The structure of the screen.

A Tangled Web - Schedule the city server.

to thinking - Who will win the computer war.

Scribble brain - Dialogues ...

Wreck Time - Advertisements and announcements ...

authors say - One and a half months later ...

Events, Facts - On Chaos Construction'99.


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

Similar articles:

В этот день...   21 November