|
ZX Format #05
11 декабря 1996 |
|
IS-DOS - the programmer: a short course in programming in the IS-DOS.

Category "IS-DOS - programmers" No 5.
music by DNK
_________________________________________
Leontiev, G.
SHORT COURSE
PROGRAMMING ENVIRONMENT IS-DOS.
(Under the general editorship Eliseev VA)
From the Editor.
Dear readers ZX FORMAT!
This short, we are entering a new and, we think, an extremely
important issue - namely, writing programs in operating system
environment IS-DOS. In connection with the catastrophic lack of
information about the internal structure of the system to So
far the development of deterrence, as many of the programmers
who want to write something in the IS-DOS faced with the need
to first understand, and as property she operates. Now,
hope the situation will change. Offered to your attention
articles by leading experts, one of the "fathers" IS-DOS Alexei
Leontiev contains some initial information that is necessary
for anyone who decided to try his forces in the programming for
IS-DOS. Thus, give the word to Alex:
*****************************************
Leontiev
WHAT TO DO?
or
How to Stop Worrying and Start
Program in ISDOSE
1. Memory allocation in iS-DOS:
Operating system iS-DOS was originally written with the
expectation of its performance in the old standard ZX 48 KB
memory and at least one drive. Therefore, in iS-DOS Classic
lower 16 KB of memory your computer is almost not used (there
is a ROM BASIC). Above, to address # 4000, is the screen.
Since the connection to the floppy disk drive via TR-DOS,
then saved some variables of Basic and trdosa.
Thus we are left with the memory of 23,900 (# 5D5C)
to 65535 (# FFFF).
Printer buffer (# 5B00 .. .. # 5BFF) is used for batch file
exebat.com, required to operate a bat-files. Area with 23,900
(# 5D5C) on 23,999 (# 5DBF) is reserved for program
mon.com and menu.com, which as well as
exebat.com cause other com-files.
The region above 24000 is usually used to load system or
user-com-files. "Komandniki" is loaded at load (12th, 13th
bytes file descriptor). At the same point of control is
transferred. 95% of all com-files has load address 24000.
Upper region of com-files is limited
cache block devices.
Cache block device contains a read through some of the
restarts blocks. It is required for almost all restarts the
service level file (with # 20 at # 38 and # 3B to # 3F), many
restarts the level of the command line, working with
files and directories, and some restarts the upper level: $
shsubr (# 8E), $ Shpanl (# 90).
When you run the com-file restarts with $ run (# 48) or $
exebat (# 44) system itself monitors the inviolability cache.
If com-file does not fit the cache, an error is generated 130.
Address cache and its size Contact your system using a system
restart $ g_cnfg (# 10):
LD C, # 10; $ g_cnfg
RST # 10
EXX; in HL - address of the vector
; System configuration
LD BC, 5; offset 5
ADD HL, BC
LD E, (HL); address cache
INC HL; put in DE
LD D, (HL)
INC HL; shift 7
LD A, (HL); cache size in blocks
Now is not difficult to verify
lacks a memory, and if not, recreate the cache (if it is needed
for the program) with a size smaller with the restart $ creat
(# 00).
If the cache is temporarily not needed, this memory can be
used, but then need to recreate the cache restart
$ Creat (# 00).
Higher cache is an area of channels.
Address, size, and a pointer field channels accrue through the
already familiar restart $ g_cnfg (# 10) with offsets 32, 34
and 36, respectively. In channels is kept the most necessary
system information such as channel drivers and devices,
channels, panels, and residents, and therefore, starting from
the address field channels and up to # FFFF is better not to
touch anything!
Over the domain channels are mixed (in order of loading)
and drivers residents. The lower will be the resident (driver)
is loaded last. Address is the lower residence at the end of
channels (see above).
Residents and drivers are available for
names c using restarts $ fndev (# 51) and
$ Run (# 48) or by number of channels or device drivers.
So any driver or a resident you
can get, knowing the number of its channels:
; To put the A channel number
LD C, # 16; $ stchn
RST # 10
RET C; out by mistake -
; Not canal, etc.
EXX; in HL - Address
; Body channel
INC HL
INC HL
INC HL
INC HL
LD E, (HL)
INC HL
LD D, (HL); in DE - Address
; Body driver
... etc.
(Description $ stchn and channels, see below)
Resident task can run
knowing the number of its channel, restart
$ Exeres (# 53).
Even higher with 5 levels of the system. They sit down, ie,
the lowest level of the "DOS" (work with devices that cache,
the channels and interrupts) is located at the top. Next come
the "DUD" (File Services), "COM" (Shell), "WIN"
(Restarts work with windows, printing lines
etc.) and at the very bottom "SHELL" (file shells, work with
panels, menus).
Two upper-level ("window technology" and "work with the
panels) may be temporarily taken off the program with key
set.com / L, but uses it rarely.
To see what where how much can be
using the program Q: UTIL \ show.com. She
lets you see all the major addresses
system, load address levels reezidentov and drivers, address,
and cache size and much more.
Example Memory Allocation
iS-DOS Classic
0 ROM BASIC
16384 screen
24000 area com-files
35903 cache
43,443 channels
44,143 residents and drivers
50304 Level 4: shell
54800 Level 3: win
58472 Level 2: com
60726 Level 1: dud
63296 level 0: dos
All additional memory ZX (128,
256, etc.) or used for virtual RAM disk that is accessed
through a special driver as an ordinary device (preferably
him to appoint a device Q:, then work in the system
dramatically speeds up), or by buffers (eg copiers).
In January 1995, created another
variant iS-DOSa: "iS-DOS Chic" (isdos
chic), which uses the lower 16 KB to host an immutable part of
the kernel. This was made possible by computers
KAY-256, Scorpion ZS-256, Spectrum-Profi
and others like them.
These modifications allow the Spectrum at the bottom of the
page memory to place the 0th memory bank. Instead, the vverhney
page opens eighth bank.
At the bottom of page are positioned as
immutable rule of the system
programs (to be able to flash this
Page in ROM) decoder t42 and
t64 (2KB +1 KB), thereby increasing transit area almost doubled
(up to 30 KB instead of 15 with a minimum number of residents
and the 29-block cache).
Example Memory Allocation
iS-DOS Chic
# 0010 rst # 10
# 003B driver routine email. Disk
# 0047 sign of the type of system / computer
# 0067 table for drivers email. Disk
# 0101 buffer driver ramdisk
# 0201 decoder t64 (1KB)
# 0601 is not used
# 093A system kernel (unchangeable part)
# 3800 decoder t42 (2KB)
# 4000 Screen
# 5DC0 region com-files
# A5A2 cache (49 blocks)
# D6F0 Channels
# DAD8 residents and drivers
# F365 level 4: shell
# F78C Level 3: win variable
# FA88 Level 2: com part
# FC0C Level 1: dud
# FDE6 level 0: dos
2. SOME COMMON WORDS:
The system iS-DOS system call routines use the command
RST 16 (or RST # 10, if anyone likes
hexadecimal). In the iS-DOS
Classic must be opened the fourth channel
BASIC (after loading the way it is,
if you just called yourself a procedure
# 1601, or did not run in isdose say
MONS-4).
The function code is applied in register C.
His elder 3 bits determine the level system. Usually they
(levels) of 5 (with 0 to 4). Additional temporary rate
the number 7 puts a text editor.
The debugger sets the level number 5.
Additional levels are set as the database.
This method of communication with the system or
own kernel package from the overlays extremely convenient,
since the kernel and overlays completely untied the targeting
and rebroadcast after the kernel does not need perelinkovyvat
all overlays. Otherwise If after changing the system had
to recompile all the command and resident files a lot of
drivers, etc. etc.
When you work the majority of restarts
system saves registers BC, DE, HL,
IX and IY. Many restarts output
value register pair AF signals about the success of the
operation. At the same time raised to "1" indicates an error
flag C and register A in this case contains her code. In most
cases, the errors we recommend simply put off by the flag C:
For example:
LD C, # 02; flush
RST # 10; call restart
RET C; output error
...
Some of the restart, such as
Restarts windowing technology $ wt, $ adrwt,
$ Box and others may come back with any flag, ie, no flag C,
nor any one else Here are a sign of errors and handle them
after the call is not restarted not only useful but also
erroneous. In Later, when more detailed consideration of
restarts for each of them will include possible errors. For
some restarts is important not only flag C output, but also
flag Z, as well as the contents of the registers. Such cases
are negotiated separately.
Most of the restart, as has been
states retain the register pairs BC,
DE, HL, IX. Exception: Restarts $ exebat
and $ run. They transferred control of a batch file or a
resident program. When leaving for RET'u of the callers
programs, we get straight to the main
program without going through the restore registers.
WARNING!
ALTERNATIVE REGISTERS
WITH RST 1916
NOT included!
Moreover, it is of many restarts in the program return
useful information such as addresses systemic vectors (arrays),
the addresses or numbers block devices, the addresses of
channels, drivers, etc., etc. The same input data You can pass
only through the main registers.
3. YOUR FIRST PROGRAM
Program in isdose may be two
basic types: batch files and residents.
Batch files (we'll talk about the resident later) have the
extension *. com and loaded at the address specified in
12 th and 13 th byte of the file descriptor, in other words,
offset 1912 dec (# 0C hex) in the descriptor file and run with
the load address. You can call them from other programs on the
command line restart run. For example:
LD HL, LINE; address command
; Line put in HL
LD C, # 48; $ run
RST # 10
RET C
, A description of the command line ends
; Code ENTER (# 0D)
...
LINE DEFM "Q: RES \ set user.res"
DEFB # 0D
From the shell command file isdosa
You can start summing to it a file
cursor and pressing Enter, or describing it in
text file Q: SHELL \ extkey.txt, or
from the monitor command line mon.res
(Mon +. Res, mon.com), as well as from
bat-file (for details, see the book Eliseeva "IS-DOS - Getting
Started").
Create a batch file that is not easy, but very simple.
First, by text editor, create original
text file in your favorite standard assembler. We recommend our
as2.com. The file must have extension *. as (some love *. asm).
At the beginning of the program Set the load address directive
ORG (Preferably not less than 24000):
ORG 24000
Then place the body of your program.
Go isdos advise on the team:
RET
At normal output flag C should
be cleared, the Z flag is set, the register A code put off the
operation:
# 00 - do nothing
# F0 - reprint a current panel
while it remains open to
Tym current directory, which was
panel before it, remains
cursor position, a mark file
reset.
# F1 - is the same, but the cursor is established
is called the top panel.
# F2 - reprint both panels, retaining
the current panel earlier open
directory and the cursor position. Rewritten
chatyvaetsya also the top line
Hints, however, monitor window
command line is not cleared.
# F3 - the same, but the cursor is placed in
top panel.
# F4 - completely clears the screen and the census
chatyvaet both the panel and the line below
tale. To preserve the current panel
varies previously opened directory and
cursor position.
# F5 - the same, but the cursor is placed in
top panel.
# F6 - a complete upgrade of the screen, the Census
Chatcombe both panels and tips
(As in F4), in addition to re-
recreated the cache. Be the cache size
is taken from vektroa g_cnfg with bias
Niemi -6. Position the cursor and kata
log in the current panel are saved.
# F7 - the same, but the cursor is placed in
top panel.
# F8 - Reprint of the current panel with the Sox
wound open directory position
tion the cursor and mark files.
# 17 - (in older versions - # FB) - census
Chatcombe current panel, while those
kuschee device on it opens
camping again (reread it Cor
two-level directory).
When an error flag C should be set in register A code is
placed errors.
Ottransliruyte program assembler otlinkuyte resulting object
program file link.com. To call them
You can write a bat-file, or you can simply
press Enter, by pointing the cursor at the first
asm-file, then obj (The file
Q: extent.txt the following lines:
asm: Q: AS \ as / auto
obj: Q: AS \ link / old / sym S: AS \ rst
Use when writing a standard name restarts, then you
handy file of global labels
rst.obj, and the program will be more readable. Be sure to
count the checksum com-file program ch.com. To do this, place
the cursor on Your com-file and call the command
line program ch.com. In the case of
bat-file describe the call directly to ch.com
it.
4. TERMINATE
Residency program in the system
IS-DOS is a program that constantly
located in a special area of memory and, therefore, available
for work in any time without podgruzki it from disk.
Working with the resident program is divided into three
stages:
1. Installation (loading) in the memory with discrete
ka, setting the address and initialization
tion.
2. The main work
3. Removing the program from memory
First and third stages are carried out
team set.com. It also creates a 18-byte channel, which
describes the resident program.
Installed (loaded) TSRs can be seen through programs
show.com and eliminat.com. Contact the resident program by the
name of the command line using the built-in command DOS "@",
for example:
@ Date +3
or
@ Scan ch + *.*
The last line contains just two
behalf of residents. This is because
Some resident programs are designed to work together with
special official residents - scan.res and
univ.res. These utilities resident selects the file (on the
mask, mark, etc.) and transmit them as parameter of the
resident, it runs in a pair with them.
T. of. You run a utility-resident program, citing
the first parameter the name of the working residents, and as a
second - a key or a mask for selection of files. The service
defines a resident by the name of the channel number Desktop
resident, remembers him multiple runs at the number pre-opening
the following file suitable for the given mask or key.
Residents, working together with residents and scan.res
univ.res usually have special protection from a direct appeal
to them via the command "@".
The structure of the residency program:
****************************************
Offset. Length comment
---------------------------------------
0 2 Address initialization procedure
tion. She called for ne
displacements (with a reg. A
served FF) or delete
(In reg. A fed FE) prog
Rummy SET.com. If this
address is 0, then the procedure
not called. This program
must be connected if it
requires the resident to the chain
kidney interrupts or other
On the other programa, intercept
restart and restore
them.
February 2 Location of the main entrance, ie
start-up procedure on behalf of
restarts $ exebat (# 44)
$ Run (# 48) or by number ka
signal restart $ exeres (# 53)
If the address is 0, then for
is started with the 4-th byte.
4 R Body program - actually
machine code
R +4 2 # FFFF - separates the body of
program of follow-up case
zhebnoy information
R +6 2n table custom Adre
owls - 1. Displacement from the beginning
calculated by the LSA. Unit
subtracted for emphasis just
you're setting up such teams
as: CALL, JP, LD HL,
LD A, (nn), the most frequently
encountered in the program.
---------------------------------------
With the advent of programs and assembler
Collector (as.com and link.com) cares
of the separator and custom table
addresses a programmer disappeared. To
collect resident task should be only a reserve at the beginning
of the file 4 bytes (2 words) to address points of entry (see
just reduced structure) and otlinkovat object file (s) with a
key / Res. Be sure to only install ORG
different from zero, to address # FFFF is not
confused with the separator!
5. Device Drivers
The driver - a resident program
special purpose. He serves
physical or logical unit of one of three types:
1. Block devices: files of type *. blk,
channel numbers of drivers F8 .. FF, facilities
channel devices - 00 .. 07
2. Symbolic output devices: files
Type *. typ and *. lpr, the channel numbers of drivers F0 ..
F7, the channel number of devices - 08 .. 0F
3. Cimvolnye input devices: files
Type *. key channel numbers of drivers
E8 .. EF, the channel number of devices -
10 .. 1F
Installed in the system the driver has only 8-character
name (type in the channel not stored). typ of lpr can be
distinguished on 0-th bit in the 13th byte of the driver
(The fifth byte in the vector g_typ (# 12)). At the beginning
of each driver is the vector of the standard structure:
****************************************
Offset. length of the name of the comment
---------------------------------------
0 2 INST program initialization
function called as
for all residents
program SET.com, and
and each transition
switching of devices
Accepted drive
rum. In the regi
A number tends served
Devices
February 2 ENTRY1 first entry point
April 2 ENTRY2 second entry point
June 2 ENTRY3 third entry point
August 8 service information
stored in
description of the channel conditions
ful and in the vector
devices - Registers
state, will address
ferov etc.
16 ... driver's body
---------------------------------------
The entry point INST can be used as a driver on the
appropriate device (involved in sys_driv and drivers drives),
and also informs the driver (and resident) of
that it moved or disconnected.
All information fed into the register A:
A = 0 .. 7 - number of devices on which
switch driver
A = FE - driver (resident) is disabled
ie will be withdrawn, or just those
kuschee device will soon be
changed. This is done to the
case if the driver in the operating
able to intercept the inversion
of to any restart or
another driver.
A = FF - driver (resident) has just
moved.
Inputs ENTRY1, 2, 3 correspond
groups of system restarts IS-DOS:
****************************************
Driver ENTRY1 ENTRY2 ENTRY3
--------------------------------------- Blk $ read $ write $
binit typ $ type $ tycpl $ typos
key $ key $ kwait $ ktest
---------------------------------------
Appendix: Structure drivers
IS-DOS Device
****************************************
blk - block device
--------------------------------------- 0 2 INSTL - switching
to a Device in
or reinstallation
(If the value is 0,
the procedure is not needed)
February 2 BREAD entry point
April 2 BWRIT to restart
June 2 BINIT (only drives
with removable media)
August 1 SCCSR - status register:
Bits 0 ... 2 - number of devices
cache
Bit 3 - 0 - driver with buffer
1 - driver with no buffer
Bit 4 - 0 - do not
autoflush
1 - execute autoflush
with each modification
cation of blocks in cache
Bit 5 - 0 - prohibition of reading for
restarts
1 - read permission
to restart
Bit 6 - 0 - ban entry for
restarts
1 - write permission
to restart
Bit 7 - 0 - do not use cache
1 - use cache
September 1 DRCSR - even the status register:
Bit 0 - 0 - do not request
at QVST
(Vector g_cnfg bias
generalization +40) at about
increment to the block
device
1 - run the query
Bit 1 - Flag autoflush (sbrasy
is called the user)
Bit 2 - 0 - TR-DOS disk
1 - CD TR-DOS does not
Bits 3 ... 6 - not used
Bit 7 - 0 - not processed
error ($ erdrv)
1 - error handling
February 10 OFIM2 - offset from the beginning
driver code to IM2
in the process of recovery
leniya mode IM2 to you
During the driver.
If the value is 0,
then IM2 at the output is not
set
January 12 TPSYS - Type TR-DOS'a:
0 - 5.01
1 - 5.03 and above)
February 14 TMBUF - address of buffer driver
Buffer Size - 1Kb.
........
Feb. 20 ..... - Number of the current sector
in the buffer driver
........
Jan. 30 ..... - Drive type:
Bit 0 - 0 - 40 tracks
1 - 80 tracks
bit 1 - 0, - one-sided
1 - Two-way
January 31 TMWT - delay start reading
Sector
32 1 HTIME - while moving holo
FOC drive
33 1 ..... - Type of drive:
Bit 0 - 0 - 40 tracks
1 - 80 tracks
bit 1 - 0 - unilateral
1 - Two-way
34 1 ..... - The size of the sector, the value
of this byte:
A - 256 bytes
2 - 512 bytes
4 - 1024 bytes
35 1 ..... - Number of sectors
track
36 16 ..... - Table numbers of sectors
ditch on the track
------- Note: Bytes 8 ... 15 are also stored
in the channel and in the vector block device. 33 ... 51 bytes
read from the disc, it is nothing as bytes 25 and 23 ...
64 ... 79 of the zero block descriptor disk. More information
about drives, we'll talk a little later, when describing the
restart $ binit.
****************************************
typ - output device for display
---------------------------------------
0 2 ..... - Usually not used
characterizes
February 2 TYPE entry point for
April 2 TYCPL restarts Print
June 2 TYPOS characters
Aug. 1 ..... - The width of the matrix of symbols
in points (6 for ty42 and
4 for ty64). Used
is restarts and y___
n___ level WIN
April 9 ..... - Reserved
Jan. 13 ..... - Must be 0
(Sign typ)
Feb. 14 ..... - Reserved
February 16 GSZ size character generator
in bytes
18 GSZ actually znakogenera
torus driver
------- Note: ... 15 8 bytes are stored as
in the channel and in the vector character of the output
device. Bytes, corresponding to a reserved used there for store
the current coordinates and address printing error handling
character output device.
****************************************
lpr - output to printer
---------------------------------------
0 2 ..... - Initialization of ports
printer if it is not
necessary
Feb. 2 ..... - How to print the symbols
la, filed with the reg. A,
April 9 ..... - Reserved
Jan. 13 ..... - Must be equal to 1
(Sign lpr)
Feb. 14 ..... - Reserved
------- Note: bytes 8 ... 15 are also stored
in the channel and in the vector character of the output device.
****************************************
key:
---------------------------------------
0 2 ..... - Usually not used
characterizes
February 2 TTYIN entry point for
April 2 KWAIT restarts I
June 2 KTEST Keyboard
August 1 K_CSR - status register:
Bit 0 - 0 - lowercase
1 - uppercase
bit 1 - 0 - latin
1 - Russian
Bit 2 - 0 - text
1 - pseudographics
Bit 3 - 0 - permission kwait
1 - ban kwait (1)
This bit is reset
himself with an empty buffer
September 1 M_CSR - mask permits change
corresponding bits
Register K_CSR
1 - change permitted
January 10 KLAST - code of the last pressed
keys
January 11 REPD - the interval between the first
two identical clusters
vishami (delay auto
repeat), the value of
Default - 29
January 12 REPP - the interval between subsequent
sponding the same cluster
vishami (the frequency of car
repeat), the value of
Default - 1
February 13 IKEYB - address of the procedure poll
Keyboard
Feb. 14 ..... - Reserved
February 16 KS - Size Code Table
Keys
1918 KS ..... - Proper table to
Dov keys
............
KS +18 1 PNKEY - the number of keystrokes
KS +19 1 - offset in buffer clusters
vish to code for TTYIN
(INC)
KS +20 32 ..... - Buffer keystrokes
(To be filled and oporozh
varies by INC)
---------------------------------------
****************************************
Well, today, and all dear
readers in the next issue ZX Format
continuation of the book will be printed A.
Leontief, which will discuss restarting the lowest level of the
system - the level of "DOS" (c # 00 to # 1F).
Other articles:
Similar articles:
В этот день... 1 December