|
Inferno #07
31 мая 2005 |
|
For Coderz - Programming under DNA_OS ZET-9, a package of tools to work with storage devices.

Programming under DNA_OS
ZET-9
29.05.2005
From here you will learn how to be ISPO
lzovat function of DNA in your prog
Rummy. This file will gradually complement
nyatsya.Poka it's just a collection of texts
describing the structure of DNA and prog
Ramm, using its function.
The system provides an external program
nyuyu (long term) memory in the form of a disk
O drives. Working with different however
Pitel carried odinakovo.P-mothers do not
requires knowledge about what type of storage ring
Telja (flexible or rigid magnetic disks,
optical disks or dynamic circuits
Scoy / SRAM), which file
system at some nakopitele.Vse for
Bots on the variety of external in-
her memory takes over the system.
Working with files is reduced to the fundamental challenge
ktsy system with the number of memory device
Islands, the name of the (sub) directory in which located
wives file (sub) directory, name the file you want /
(Sub) directory, and type of operation that the neo
bhodimo to use the file / (sub) directory:
read / write / create / delete.
Modes of memory allocation
The system operates in 1 mode, 2-nd yet
not used - in reserve:
1 - single-tasking mode
The memory is the core of the system and n-ma.
U-ma can use different modes
interruptions (including IM 2), pereustana
pour in the stack, etc. In this mode of operation
n we almost do not differ from that of normal
TR-DOS n we have but to call disk functions
use function calls the system (through
resident system), and instead of a direct C / O
lyucheniya pages through the ports of the n-ma used
em driver paging pamyati.Drayver we find
reduces to the resident system, and a resident of the system
threads located at the bottom of memory (now
23296-23551). The system also uses about
domain # 5d40 .. # 5fff. Thus, the n-metal
available screen area (16384-22527)
region from 24576 to 65535 and page parameters
crease, with the exception of systemic stranitsy.Pri
call disk functions, the system in its
discretion, may include a trap mode
IM 1 (if there is an appeal to TR-DOS) and OS
accorded him. U-ma should take this into account.
In case of shortage of low memory n-ma
can use the field 23296-24575,
saving it in free of
region and to restore 23296-24575
appeal to the resident sistemy.Pered ZAPU
Scoma n we have in this mode is activated 0-I
page.
2 - mode "task switching"
Available in the presence of upper memory
(> 128k), actually d / b 512k (if not used
forms a RAM-disk) or 1024k.Otlichaetsya those
that in the upper memory may be other
Gia-n us. Therefore, before using
vat top page of memory in this mode
ME, you should check whether it is free.
Page is considered free if the village
glacial bytes in the page is 0. Otherwise, there
is another n-ma, and use the country
ary can not.
In this mode, possible temporary output
of n-we maintaining the current status
("Folding"). For this n-ma should by
revenge of the non-zero bytes in all the pages in
which will retain the code / data, and Cox
wound screen and 24576-49151 in stranitsah.Po
following this control is transferred to the resident
Dent, a procedure in the Released obolochku.V distance
In what follows it will be possible to return to the n-th at
This control is transferred to the address 49152
in the main page of the n-us - one that results
zerviruetsya for "we-axis. It turns
When downloading files from the n-me.
P-axis is we have the extension. SEP and
loaded with the addresses of 24576 and 65535. If
n-file, we are longer than 40960 are loaded first
curves 40960 bytes.
Before the release of n-ma must itself osvobo
all sums pages that use,
otherwise, these pages will be available to other
n-mom (should be placed at 0 to # FFFF
every page, including main).
The first entry in the program
After booting from the address # 6000 control
of transmitted n-metal. IX points to the table
face with dannymi.P-ma should take from the table
particle required her data for further ISPO
lzovaniya. See "Block data transfer
given by the program at startup.
When receiving a message # 0001 n-ma long
zhna take the name of the file and pro
carry with it the operation according to the destination
n us. (Download the file and "show" him to
example: playing music, images, text - you
to the screen, the archive - unpack ...)
Re-entry into the program
If n-ma was "rolled", it can be
return. Return by any of the
shell, or from another instance of n-us.
Included is the main page of this
n-us, control is transferred to the address 49152.
Register pair IX points to the table
parameters. Relevant bytes IX-2, IX-1
(2 bytes) - message n we. May, at
take the values:
# 0001 - open the file (see above);
# 0002 - to complete the n-us (it's from
communication means that the user wants to
remove the n-th of the memory);
# 0003 - n-ma was the current (user
Tel switched to this n-th).
Resident System
All calls are made through
Resident of (its address is passed
p-metal on the first run).
Resident has 3 entry points (so far):
1-I entry point
Resident Address 0: call drivers countries
bital memory to switch pages. In
register pair DE transmitted number countries
boundary. If your computer has a page with
this number, it will be included, while
flag is set Z. If your computer
No page with that number, reset
Flag Z, and will be a maximum reg.pare HL
page number for this company (for 128k
- 7, 256k - 15 for 512k - 31 for 1024k
- 63, etc.).
Additional functions are called when
DE = 2, it uses the register C:
C = 0: insert page number 2 (ie
32768-49151 area to be plugged in to
region of 49,152)
C = 1: turn on the 1 st screen (will be visible
screen with the address 16384);
C = 2: enable the 2 nd screen (will be visible
screen with the address 49152 in page 7);
C = 3: enable ROM BASIC 48;
C = 4: Enable ROM BASIC 128;
C = 5: to obtain information on the inclusion
page, screen, and ROM. Returns:
DE = number of the last page included;
B = bit 3 = 0 is on the 1 st screen;
B = bit 3 = 1 is on the 2 nd screen;
B = bit 4 = 0 enabled ROM BASIC128;
B = bit 4 = 1 enabled ROM BASIC48;
HL = maks.nomer str.dlya this company.
2-I entry point
Resident Address 2: Exit to the shell.
Here n-ma should transfer control
shutdown, or when "turning
Research Institute. "
Be launched, user subroutine
Vatel, located here in the residence.
Depending on this subsequence, we will be implemented
Implemented a transition in the ROM BASIC128, either in ROM
TR-DOS with the launch of boot'a, or go into
CACHE, or search the n-us-shell and
transfer of control to it, or out in the definition
divided the page in the STS, in ALASM (depends
the contents of subroutines).
3rd entry
Resident Address +4: call f-functions of the system.
Here should transfer control to
cause any of the functions of the system. At the same time
in Reg. pair IX should be addressed to the table
Call settings (see "System functions").
And the table itself should be located in
lower memory (the last byte long table
wives have the address below 49152, the system behind it
It should not, so wash your hands before eating).
System Boot
1. First, the memory should be placed
boot axis (welcome any variation
Options):
a) The loader is copied from ROM to RAM
when selecting a menu item (as KAY-1024
click "HDD Boot");
b) is loaded from external media (in
a separate n-us, either as signature-ma other
On the other n-us - eg., plug-in to Real_Commander);
c) your option (perekidyv-found from Cache,
loaded with the cassette:)).
Loader system - a signature-ma, intended
values for kernel with CASE
physical y-va. Examples: boot from the HDD,
CD-ROM, from a specific page top na
cards, an out of the cache of the 4 th page memory (at some
toryh there a printer driver that someone Gluk
Service). The kernel will be downloaded to address
# BE00, and it is passed control.
2. The kernel sets the stack, then oprashi
Vaeth press "Space". If not pressed, Loss
zvoditsya attempt to download configuration files
radio from the boot of Islands from the root CA
Taloga:
a) file HIMEMORY.DNA - Driver Strání
chnoy memory for your computer.
After a successful download, it installs
In further work is being done with it.
b) SYSTEM.DNA - file transfer system
variables (in its description of the logical y-in, but
measure of the boot, system, quick, those
kuschego and Islands to swap a page in which the
must reside at the core of the work, and
etc. More details below). After a successful zag
manual ultrasonic inspection of the core would be moved to the
specified Page will continue to work there. Attention
attention! number is now in boot Islands may
change, and no further files will be loaded
his wife with him.
a) CONFIG.DNA - file with names of cars
starting n-we named E-Tov, who
should be installed in the system. After
successful download of the file takes the name of the author
tostartuyuschey n we (ie n-us, which will be
loaded first): This is the first 8 bytes of a file.
The downloaded file and burn to # 8000.
3. Loaded n-ma CONFIG.SEP. It Be
retract the names of elements onto starting at address # 8009,
the first 8 bytes of each line (the end
line - byte 13), end of file - bytes 3.
U-ma looking at the root of bootable
Nogo y va el-you with the names (fi
ly. DNK), loads them into the system country
ary, establishes a chain adjusts
to the load address - and now the elements of a hundred
novyatsya part of the axis.
All of these configuration files are loaded
to address # 6000.Esli files are missing or
can not download them (error reading and
etc.), then they will not be installed in the system
mu.
If the key is pressed, "Space", misses
tsya retrieve all the configuration files.
4. It will be loaded with n-ma named
SHELL.SEP (or with a different name, taken from
File CONFIG.DNA) from the root directory
BOOT y va. At the same time that the n-metal transformation
Page delivered with the number 0. After
successful loading control is transferred
n-metal. Otherwise, the 7-th page in the STS, to the address
56064 (if there is no STS'a - zavison).
Theoretically, it is assumed that the loaded
nounced n-ma - a shell, and almost
can be any n-ma.
Shell program
U-ma-span can be any (this can
can be even Real Commander 2.6 with acc
tstvuyuschimi plug-ins). it must provide
vat following functions:
- Provide information to the user
of n-grammes, which are in the pages of memory,
the ability to select and switch
one of them.
- Provide user directories with-in
and the ability to run the n-th files (SEP),
as well as the ability to open files corresponding
sponding n-mami.Dlya last shell
ka download a file EXTEND.TXT, which is long
wives placed on the y-ve with an opening
file takes the name of it n we have-in at
that this program is located (number
0-9, or S, W, T, Q, L - ie: system for
swap, current, quick, boot) and vyzy
Vaeth system to start this n-system (of which
rnevogo directory). If the file EXTEND.TXT
No, the shell searches for it on the systemic in-ve.
(Example: A user clicks on the file *. SCR
- Is a picture in the file name specified n-we
OPEN_SCR.SEP, will be loaded this n-ma, and
she loads the *. SCR file and displays it
on the screen.)
In this shell will be ne
transition from the other n-m (but not necessarily for
depends on the routines of residents).
Data block
passed to the program at startup
The maximum block length 768 bytes, this
hour block located starting at address
# 5d00.
When you start the n-ma gets control
tion, the register IX indicates the block address
Data + 15.
The block of data as follows:
IX-15 defw X; data length of opened
file
IX-13 defw Y; length of the data about the parameters
run (Keys)
IX-12 defw Z; data length of the running
nth
IX-10 defb 0; location system memory
Tee PC: 0 - in the page
IX-9 defb 0; mode of the system:
0 - single-tasking
IX-8 defw 0, the page number where the system
and a buffer for directory
IX-6 defw 0, length of residence
IX-4 defw 0; address resident system
(Now # 5b00)
IX-2 defw 0; message-e for n we have from the system:
0 = first run;
1 = First + run to open the file;
other messages until
not used (see above)
IX +0 defs Z; here Z bytes - data about
running the n-th.
(Max = 352 bytes)
IX + Z defs Y; here Y bytes - data about
startup parameters (keys)
(Max = 49 bytes
if IX-13 is not equal to 0)
IX + Z + Y defs X; here X bytes - data about
Open the file.
(Max = 352 bytes)
Total 15 +352 +49 +352 = 768 bytes.
The first step is n-ma should take the address
Resident (IX-4), then checks the community
of the system (IX-2) - whether to open
file (ie the user runs the file, and
Shell runs the nth), or user
Tel himself launched the n-th.
Data about running the n-th-n needed ME
if:
- It consists of several files,
this case, n-ma takes this data and vyzy
Vaeth element of DOS, to get the rest
files;
- Or n-ma wants to keep his spirit
Key to file *. ini, then it saves the
file back to where she is located;
- Etc.
Function of the system DNA version 0,431
Elements are selected by name (8 bytes on
at IX).
Element SYSTEM
Inputs: IX +8 (1 byte) - the number of
function.
The function 0
(Get the system variables)
IX +9 (2 bytes) - the address of where to put to
anisotropy of the system peremennyh.Potom n-ma should
add 5 to the address and use them.
System variables have the property of
me:), so you need to get them
immediately before use.
Function 1
(Set the OS)
IX +9 (1 byte) - the desired mode of operation:
0 - single-tasking mode
1 - the switching of tasks
2,3 - multitasking
5 - to restore the previous mode of operation
Element RUNEXE
Runs programs (files with the extension
eat SEP). If n-ma wants to start another
nth, it must prepare a data block and
cause element RUN_EXE.
Block of data transmitted e-tu RUN_EXE:
IX-2 defw 0; here is a message from
e-ta RUN_EXE about the result
execution in the case
any errors
IX +0 defb "RUNEXE"; name e-ta 8 bytes
IX +8 defb 0; reserve
IX +9 defb 1, 0, first run
1-Start with opening the file
IX +10 defb X; name length n we have X
IX +11 defw XX; shift before the name
n we have from the XX IX +0
IX +13 defw YY; shift before the name
file to be opened by IX +0
IX +15 defb Y; path length n-metal
IX +16 defb Z; dl.puti the opened file
IX +17 defb W; dl.imeni of the file
IX +18 defb V; length of the startup options
(Number keys)
IX +19 defb 0; number of islands where the file
IX +20 defb 0; length subdirectory where the file
(In blocks of 256 bytes)
IX +21 defw 0,0; top of the tackle. Where a file:
0 - in the root directory
IX +25 defb 0; number of islands, where n-ma
IX +26 defb 0; length subdirectory, where n-ma
IX +27 defw 0,0; top of the tackle., Where n-ma
IX +31 defs X; name n we
IX +31 + X defs Y; data about the path to the n-metal
IX +31 + X + Y defs W; the name of the file
IX +31 + X + Y + W defs Z; data about the path to
opened file
IX +31 + X + Y + W + Z defs V; start options
n we have (keys)
Element DOS
Disk function. Inputs: IX +8
(1 byte) - the number of functions.
The function 0
(Initialization logich.u Islands)
IX +30 (1 byte) - the number of logical. y-va.
Be caused by the driver block input-you
Water for the y-space with a function 0 - Ini
socialization.
Function 1
(Call file system driver)
To work with the files necessary vyzy
vat precisely this function.
IX +28,29 (2 bytes) - number of f-tion and under
function driver filesystem:
0 - initialize the file system. By
IX +30 offset will be placed the name of the file
system, 11 bytes (for example: TR-DOS).
1 - installation directory (to make the current
this catalog). Number of sub-functions:
* 0 - root
1 - the name of the buffer
* 2 - up to the level (output from the current
schego subdirectory)
* 3 - name + full path in the buffer
2 - create. Number of sub-functions:
0 - file
* 1 - subdirectory
3 - delete. Number of sub-functions:
0 - file
* 1 - subdirectory
4 - to download. Number of sub-functions:
0 - file
1 - subdirectory
5 - to write. Number of sub-functions:
0 - file
1 - subdirectory
* 6 - rename. Number of sub-functions:
0 - file
1 - subdirectory
* Feature not (not yet in the system)
For functions 2.6 file name / subdirectory
must be specified in the buffer. These operations
performed in the current subdirectory.
Block of data transmitted e-To DOS:
DEFW 0; IX-23; kontr.summa variables DOS
DEFB 0, -21; data block length
; In the sectors of 256 bytes
DEFB 0, -20; length of the path to the file
DEFB 0, -19; smesch.do beginning of the file name
DEFB 0, -18; file name length
DEFB 0, -17; BYTES IN FILE KONECH.BLOKE
DEFW 0,0; -16; LENGTH OF FILE IN BLOCKS
DEFB 0, -12, length of current directory
DEFW 0,0; -11; NACH.BLOK Current Directory
DEFB 0, -7; offset within the cluster
, (In blocks of 256 bytes)
DEFW 0,0; -6; starting number blocks of the file
DEFW 0, -2; ADDRESS BUDET
PARAMETR
DEFB "DOS"; +0; ELEMENT NAME DOS
DEFB 1; 8; FUNCTION ELEMENT DOS
DEFB "TR_DFS"; +9; ELEMENT NAME WILL DFS
; DEFB "PAGE_DRV"; +17; FILE NAME 8, if the length
; Name = 0. If the name length is not 0 (bytes from
, -18), There is the following:
DEFB 0; 17; reserve is not used
DEFW XX; +18; offset before the path
; A file from +17
DEFB X; +20; length of the path to the file
DEFB Y; +21; file name length
DEFW YY; +22; shift before the name
; File from +17
DEFB 0; 23; reserve
DEFB "DNA"; +25; file extension, with a length
; Behalf of 255 bytes
DEFB 4,0; +28; NUMBER F-IIC and sub-DFS
DEFB 0; 30; NUMBER OF THE CURRENT ARRANGEMENTS
DEFB 1; 31; boot flag:
; Bit0 :0-In ADR.IZ DIR., 1-In these ADRs
; Bit1 :0-entire file; 1-specified length
; Bit2 :0-FROM THE BEGINNING OF FILE-1-C UKAZ.SMESCH AZ
; Bit4 :0-beg. With the file; 1-cont.
; Bit5 :1-CONVERT. Univers.formu catalog
DEFW # 6000,0; +32; load address
; IF FLAG =% xx1
DEFB 0,0,0,0; +36; LENGTH DOWNLOADS,
; IF FLAG =% x1x
DEFB 0,0,0,0; +40; SHIFT BOOT,
; IF FLAG =% 1xx
DEFB "FDD_DRV"; +44; HERE TO Name E-TA
; DRV
DEFB 0; 52; NUMBER OF THE DRV
DEFW 0,0; +53; starting number Block 0 ... N
DEFW 0,0; +57; NUMBER OF UNITS
DEFW 0,0; +61; ADDRESS WHERE / WHERE LOAD / SAVE
DEFB 0; 65; NUMBER VIRT.DISKA
KUS_AUTO1
DEFS 256, 66, is the path and file name
, (If the name length is not 0
, And the path length of 0)
ELEMENT DOS out the names DRIVERS FAI
Lovoy SYSTEMS AND block I / O (DFS
And DRV) YOURSELF.
Almost need to change only the flag
operation, the address of LOAD or SAVE, the shift from
beginning of the file (if the flag is "rough
zit at the specified offset) and length of the piece
for LOAD / SAVE (if the flag is "rough
zit specified length).
U-ma takes data obtained by entangled
sk, copies of its address space,
change some parameters and calls
e-t DOS. Register IX should point to the
name e-ta DOS.
E-m DOS monitors the integrity of the data
GOVERNMENTAL about the file you are working with n-ma. Under
read checksum (CRC16), from
beginning of the DOS data takes 53 bytes.
If you opened the file was not loaded
(Recorded) at a time, then the following about
increment must be set the flag "continued
live with the file. "Otherwise, each of
increment of the driver will load the catalog and
look for the file there, and then read / write
vat.
If the load / save data indicated
zannoy length, and flag-ship at the specified
bias "is not set, then the shift
within a file is changed avtomaticheski.T.e.
if 3 times to call DOS and every time zag
Rouge 1 kb, the first kilobyte would zag
Disarmament Affairs since the beginning of the file, the next
KBytes will be loaded with the displacement of 4 (4 blocks
256 bytes), and the third will be loaded kilobytes
at offset 8 (8 blocks of 256 bytes of on
We first file.)
Flag-ship at the specified offset "
need to provide random access
the data within the file, and if the sequence
Mr. access (eg, copying) it
not need to install.
Error Codes
To the application as a message
2-byte. If both bytes are zero,
then there are no errors.
1-st byte - conditioned room e-ta (IX-1);
2-nd byte - number of errors (IX-2).
For all e-Tov common error numbers
are:
0 - no calling function (subfunction)
(After this error, the application can you
give a message to the user such as "update
element).
1 - wrong command options (checking
ka on your settings, is only
in the E-max, where the launch of c non
lnymi parameters can damage the system
IU).
2 - corrupted data in a data table
(Meaning that some spoiled
variables caused by the element).
Conditional number of elements:
0. Element FINDER (looking for e-t in the chain and
calls it).
0 - in a chain e-Comrade is no e-ta with the indicated
zannym name.
1. Element SYSTEM (System Manager
resources).
5. Element DFS (filesystem drivers
we).
3 - there is no file with the specified name (if
reading / deleting a file / directory);
4 - file with that name already exists (for
create a file / directory);
5 - There is no place in the directory (when creating
file / directory);
6 - No disk space (when you create
file / directory);
7 - end of file (when trying to read /
records for the end of the file / directory).
6. Element DRV (driver block I / O).
3 - no virtual disk with the specified
number;
4 - y-in is not ready;
5 - I / O errors. Then there will be
introduced errors for each operation separately
but (read / write).
14. Element RUNEXE (runs) files.
15. Element of DOS (disk manager in-c).
3 - do not have islands with a given number.
Format (sub) directory
(Universal form)
2 bytes - number of files downloaded
real part catalog (M);
2 bytes - number of files in all SC
Taloga (N).
Next to each of the M files to X +16
byte:
offset length description
0 a file name length (X)
The value of 1 byte is equal to 0, takes
tsya as 8 (ie, file name length 8 bytes)
file extension is 3 bytes.
+1 5 length of the file in bytes
6 2 file attributes
1-st byte (from FATx):
bit0: read-only;
bit1: invisible;
bit2: systemic;
bit3: volume label;
bit4: directory;
bit5: archive;
bit6-7: Reserve.
2-nd byte - a reserve.
8 4 time the file was created
1-st byte: bit0-5 - minute (0 .. 59);
1 st :6-7 and 2 :0-2 - clock (0 .. 23);
2-nd :3-7 - the number (1 .. 31);
3rd :0-3 - month (1 .. 12);
3rd :4-7 - st.chast year minus 1982;
4 th: ml.chast year minus 1982.
Example: The date the file was created March 26, 2003
year 9 hours 30 minutes - we
30 +9 * 64 +26 * 2048, 1 st and 2 nd bytes.
2003-1982 = 21 years (mean over 4 bits
year, equal to 0). The third byte is 3 +0 * 16 = 3.
4-th byte is 21.
+12 X filename
+12 + X 4 the file extension
Example: suppose in a subdirectory Raznoe 4
file, all files have the same length of name:
HIMEMORY.DNA
spectrum_os_history.text
The Best Games for ZX-SPECTRUM.hlp
Well, just for a very long sverhimya
file that does not fit into either
file system, but a universal form
directory provided by operating
system DNA.joke
After calling the "download subcategory
Taloga named Raznoe, starting at address
ADRESS and convert it into a universal
nuyu form (must be set bit 5
flag operations), we obtain at ADRESS:
4,0; 2 bytes - number of files
; In a busy part of the catalog
4,0; 2 bytes - all files in the cat.
And the first file
0 0 name length: 0 -> 8 bytes name
And 3 bytes of extension
1 255,0,0,0,0 the length of the file 255 bytes
6 4,0; 2 bytes of file attributes
, Set bit 2 - System
8 0,0,0,0 4 bytes: file creation time
+12 "HIMEMORY"; 8-byte file name
+20 "DNA"; 4 bytes of the file extension
And the second file
0 19; file name length 19 characters
1 0,100,0,0,0, file length 25600 bytes
6 2,0; file attributes: bit1 - read only
8 0,0,0,0, file creation time
+12 "Spectrum_os_history"; 1919 bytes name
+31 "Text"; 4-byte extension
And the third file
0 30; file name length of 30 characters
1 0,100,0,0,0, file length 25600 bytes
6 2,0; file attributes: bit1 - read only
8 0,0,0,0, file creation time
+12 "The Best Games for ZX-SPECTRUM"
; 30 bytes name
+42 "Hlp"; 4-byte extension
, The fourth file
0 167; file name length 167 characters
1 0,100,0,0,0, file length 25600 bytes
6 2,0; file attributes: bit1 - read only
8 0,0,0,0, file creation time
+12 "Well, just for a very long sverhimya
file that does not fit into either
file system, but a universal form
directory provided by operating
system of DNA "; 167 bytes of name
+189 "Joke"; 4-byte extension
Designed directory format allows
submit any known (to me) (TR-DOS,
NEOS, iS-DOS, FAT12, FAT16, FAT32, VFAT, CDFS and
etc.) file system in a universal form
metal without loss of information about files. As will
children available to catalog other files
tems (NTFS, UFS, and the like), unknown
but: (
It turned out that we should still be stored somewhere
the length of the BASIC file, when he one-piece with a finite
dovym block, and then, when copying to
y in the file system TR-DOS, put
this length. And at the moment is put on
schaya length monoblock.
Other articles:
Similar articles:
В этот день... 14 November