Nicron #23
06 марта 1997

Programming - a course of study assembler Wlodek Black, continued. Monozagruzchik.

<b>Programming</b> - a course of study assembler Wlodek Black, continued. Monozagruzchik.
                                                           z80


[Continued (in readers' letters)]

(C) WLODEK BLACK

            MONOZAGRUZCHIK

... Hello again, friends. I hope you have not erased files
great demos of all time named
"DIGITAL TUNE 1"? We return to our ... Hmmm ... Okay, we
just come back. In the past (or rather, one might say, the year 
before ...) once we got to the point where before our eyes 
appeared 4 files are the compressed data - one for each of the 
pages 19, 20, 22 and 16. I packed LZPAC-ohm, and I turned the 
following figures: dt1.19 <- 4472 bytes, 18 sectors;

dt1.20 <- 4812 bytes, 19 sectors;
dt1.22 <- 4494 bytes, 18 sectors;
dt1.16 <- 6410 bytes, 26 sectors.
I used the names for files built on the principle: "dt1" -
the words "digital tune 1" "19" (also "20", "22", "16") - number
page RAM "<" - means that the file is packed (ie, became
less "). Of course, you can use any other names.
Anyway in the end everything will turn into a single
file.
Now let's merge these 4 files into one. Download the "dt1.16 <"
address 28964, and subsequent files ship close to each
groomsman, ie "dt1.20 <" ship to address is 28964 4472, and so
on. Then unload the big file:

  SAVE "dt1. <" CODE 28964,20188.
Check the following: 28964 20188 = 49152, ie, the boundary 
started switching pages of RAM. In this case, the memory is the 
place to take immediately the entire volume of packed codes. 
Then start the program "raspihaet" individual pieces of code 
block on page 19, 20 and 22. By the way, we still have packed a 
picture! 

        A set of standard functions TR DOS.

For programmers writing in assembler, TR DOS provides
fairly extensive set of so-called standard functions that 
perform these necessary actions, such as working with files and 
separate tracks and sectors - search, read, write - and more. A 
complete list of features can be found in any instruction to 
the computer, which provides guidance on the use of TR DOS, so 
here I will not repeat. I can only say that to refer to the 
standard functions TR DOS to Record number calls a subroutine 
in register C and perform CALL # 3D13, a pre zanesya input 
parameters in other registers. For us now it is of interest 
feature number 5 - reading group sectors. Input parameters for 
it are starting track and sector and the number of read 
sectors, as well as the address to which you begin to download 
data: DE - initial track / sector (E - Sector, D - Track);

B - number of read sectors;
HL - address of the boot.
File structure of disk TR DOS is very simple. Files are stored 
on disk in the order they appear in the directory. Each 
subsequent file starts with the track / sector, going beyond 
the last sector of the file. System variable TR DOS, located at 
# 5CF4 (two-byte word), keeps track number and sector, 
following after the last read sector. Upon completion of 
download of any file in this cell will be like a pointer to the 
beginning of the next file. Based on the above, it is easy to 
assume that you'd like to download the following file (or any 
part thereof) - we must take meaning of a word from a cell # 
5CF4 and put it in a couple of DE as the "track / sector" for 
the function 5:     LD HL, adres_zagruzki

    LD DE, (# 5CF4)
    LD BC, # XX05; where XX - number of loaded sectors
    CALL # 3D13.
To use such admission must comply with the simplest condition - 
the files to the boot sequence should be recorded one after 
another without having erased files between them. And now - 
please! With the file type "BASIC program" TR DOS operates with 
one interesting feature: when downloading Beysikprogrammy for 
execution TR DOS takes from the disk directory file length in b 
and d t and x, not paying attention to the length in sectors. 
It calculates the number of sectors corresponding to the 
specified directory in length, in bytes, and the ship just 
enough. If Beysikovy loader has a length of, say, 209 bytes and 
the length of the sectors listed, for example, 68 - on command 
"RUN" or "LOAD" will be loaded only one sector corresponding to 
the size file of 209 bytes. That this implies a great 
opportunity to join together into one file and Beysikovy 
loader, followed by a block of code. You can do this, of 
course, vruchnuyuslozhit length boot sectors and the subsequent 
file (s) Record the result in the file length in sectors BASIC 
loader, and carefully remove from the catalog of obsolete 
pointers (handles) on the data files. And then adjust data in 
the 9-m sector, so that the number of files has been turned out 
and match the options "the first free track / sector", "number 
of free sectors" carried in themselves the true values. This 
can be done by any "disk doctor". Work, of course, not too 
complicated, but if you make a mistake, the very first new 
recording on the disc will fail! Fortunately, there are tools 
with which to "merge" the files at the touch of a button, and 
without any risk. One of the most famous of these is the 
Advanced Disk Monitor - ADM 7.08. To merge files in the ADM 
point to the initial file, and then Symbol Shift + C (connect - 
connect). In your eyes lower part of the directory "tighten" to 
the original file, subsequent to the the initial file will 
disappear, and the initial file popolneet the value volume of 
"missing" file. Operation can be repeated for podlivaniya more 
than one file, etc. Consolidate the changes made by using the 
rename operation: press N; if necessary, rename the file, press 
Enter. The result is written to a directory on disk. In 
conclusion, cite the full text of the loader and start the 
program for the demos "DIGITAL TUNE 1" with comments: 

    DI
    LD HL, 50000; load address packed pictures
    LD DE, (# 5CF4); track / sector
    LD BC, # 0F05; 1915 (# 0F) sectors to read
    XOR A
    CALL # 3D13; call TR DOS
    CALL 50000; unboxing pictures on the screen
    DI
    LD HL, 28964; load address of the main unit
    LD DE, (# 5CF4); track / sector
    LD BC, # 4F05; 1979 (# 4F) of sectors to read
    XOR A
    CALL # 3D13
    DI
    LD A, 19, page number
    LD HL, 35374; start address data for page 3
    LD DE, 4472, the block length codes
    CALL LDIRDT; sends to the third page
    LD A, 20, also for 4-th page
    LD DE, 4812
    CALL LDIRDT
    LD A, 22, also for 6-th page
    LD DE, 4494
    CALL LDIRDT
    LD HL, 35373; move
    LD DE, 37641, in its place
    LD BC, 6410; block codes
    LDDR; main memory
    CALL 31232; extract the main unit
    LD A, 23; includes 7-th page (as necessary)
    LD BC, 32765
    OUT (C), A
    EI
    CALL 31238; initialize music
LOOP: CALL 31232; losing DeMouy
    JR LOOP
LDIRDT: LD BC, 32765; routine raspihivaniya from memory
    PUSH BC
    OUT (C), A; includes a page
    LD C, E; transfer from DE to BC, how many bytes ...
    LD B, D
    LD DE, # C000; ... should be forwarded to the address # 
C000 ...     LDIR; ... and forwards

    PUSH HL
    CALL # C000; extract
    POP HL; restore HL and BC
    POP BC
    LD A, 16, restoring the main memory
    OUT (C), A
    RET; return.

That's it. Bye!

[Continuing the theme of "assembler" should be].





Other articles:

Entry - the contents of rooms and poems.

BBS - list of stations BBS ZXNet.

Programming - a course of study assembler Wlodek Black, continued. Monozagruzchik.

solve the problem - restore a disk, Disk error trk.0 sect.8 (9).

Graphics - Image ANSI graphics.

Humor - From the readers' letters to the journal "Health".

Humor - anecdotes.

Search - search for game programs.

Humor - marasmus.

Advertising - advertising and announcements.

Feedback - contact the publisher.


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

Similar articles:
ZX Spectrum and the hard drive - Article Vlad Sotnikova / Vega about work and programming of the hard drive (HDD) on the Spectrum.
Events - the official results of Chaos Construction 2004.
Presentation - All programs: What can FORTH?

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