eg2000 dos
Colour DOS
A guidline for the Disk Operating System
of the EACA EG2000 Colour Genie Computer
Table of Contents.
1. Introduction............................................................................................................................................................1
2. Floppy disk composition ......................................................................................................................................2
3. File formats..............................................................................................................................................................4
4. The File Control Block (FCB) ...............................................................................................................................5
5. DOS routines ..........................................................................................................................................................6
6. Interrupt routine format.......................................................................................................................................15
7. Compatibility with TRS 80 / Video Genie Operating Systems .......................................................................16
8. Floppy disk formats .............................................................................................................................................17
9. Reading alien floppy disks .................................................................................................................................18
Appendix A: Disk BASIC Memory usage............................................................................................................19
Appendix B: Memory map......................................................................................................................................20
Appendix C: Error codes .........................................................................................................................................21
Appendix D: System Entry Table ..........................................................................................................................23
Appendix E: Description of the Restart commands............................................................................................24
Appendix F: Vector tables for DOS / Disk BASIC ..............................................................................................25
Appendix G: Program examples..............................................................................................................................27
1. Introduction
This document contains helpful information about the functioning and a more extensive use of DOS on the
EG2000 Colour Genie computer. It gives an overview of the details of DOS, and how to access DOS from
assembly language programs. Some program examples are included.
1
2. Floppy disk composition
This chapter gives an overview of the way that floppy disks are formatted and how the data on the floppy disk is
distributed and managened.
The smallest data unit on a floppy disk is one sector. One sector always contains 256 bytes. Sectors are
numbered. Machine programs can access sectors directly for either read or write operations.
Every 5 consecutive sectors form a granule (1280 bytes). In a normal floppy disk composition in files, that are
addressed with their filename, the granule is the smallest addressable unit. This means that every file occupies
a certain number of granules. This can lead to the situation that DOS reports a floppy disk that contains a lot of
small files as full, although the majority of sectors is unused.
Another unit that is important in the use of DOS, is the lump. The size of a lump depends on the floppy disk
format:
Floppy disk format
A,E,I
B,F,J
C,G,K
D,H,L
(SS,SD)
(DS,SD)
(SS,DD)
(DS,DD)
Granules per lump
2
4
3
6
During formatting, 2 system files a written onto the floppy disk. These system files are hidden, and are not
listed using the CMD"I" command:
DIR/SYS
This file contains the directory of the floppy disk. This is the only file that contains protected sectors. This
means, that when reading this file, an error 6 is reported. This serves as an extra protection and recognition of
this file. DIR/SYS differs in length depending on the floppy disk format.
NCW1983/JHL
This file always occupies the first granule (sector 0 to 4) on the floppy disk. Its main task is to make the floppy
disks compatible with the operating systems for the TRS 80 and Video Genie computers (there it is called
BOOT/SYS and it contains the load routine for DOS). On the Colour Genie, only the third byte of the first sector
is important; it indicates, in which lump on the floppy disk, the directory starts.
For studying the floppy disk composition, a program like Colour-Zap is strongly recommended. Such a program
allows you to look at the sectors on the floppy disk.
The first sector of DIR/SYS contains information about the floppy disk. The bytes 00H to 05H indicate the free
granules on the floppy disk. Every byte corresponds with one lump. Starting with bit 0, only that number of bits
is used, that corresponds with the number of granules per lump. So, bit 0 of the first byte indicates whether the
first granule on the floppy disk is occupied (this granule is always occupied by NCW1983/SYS). If a granule is
occupied, the corresponding bit is set to 1. Unused bits are always set to 1. A completely used lump has its
corresponding byte set to FFH.
The bytes 60H to BFH are not used by the Colour Genie. They are used in some TRS80/Video Genie operating
systems to indicate defective granules.
The bytes D0H to D7H contain name, the bytes D8H to DFH contain the date of the floppy disk.
The remaining bytes of the first sector have no meaning on the Colour Genie.
The second sector of DIR/SYS contains the hash code table for several files. Here, for every file, a hash code
from the name is stored to speed up the search of a file. The position of a hash code in the second sector
indicates, where the real entry in DIR/SYS is located. When one would imagine this sector as a table with 8
rows and 32 columns, then every column contains the hash codes for one of the next sectors. Column 0 for the
2
third sector, column 1 for the fourth sector etc.. When a byte is 0, it means that there is no file entry at the
corresponding location.
Byte 1FH of the second sector has a special meaning. It indicated the length of DIR/SYS-10. So, when is
contains 5 (as with SS/DD floppy disks), DIR/SYS is occupies 15 sectors.
The next sectors contain the file entries for the files present. Every file uses a block of 32 bytes, one sector
can hold up to 8 files. There are 2 types of entries:
The first (and in most cases only) entry for a file and its continuation (necessary for long files, when the file is
stored on different locations on the floppy disk). The bytes of the first entry contain following information:
Byte 0:
Bit
7
6
5
4
3
2-0
Meaning when set
Always 0
System file
No meaning
Entry in use, contains a file
Hidden file, not listed using CMD"I"
Always 0 on the Colour Genie
Byte 1:
Bit
7
6
5-0
Meaning when set
Always 0
System file
No meaning
Byte 2:
Byte 3:
No meaning
Indicates which byte in the last sector of the file does not belong to the file
anymore. Here the rule is 0=256.
Not used by DOS
Contain the file name, padded with spaces.
Contain the file extension.
Always 0 on the Colour Genie
Indicate how many sectors are used by this file.
Byte 4:
Bytes 5-12:
Bytes 13-15
Bytes 16-19:
Bytes 13-15
The remaining bytes indicate the location of the data. It is possible that the file is divided into several blocks.
For this reason, 4 pairs of bytes are reserved. If they are not sufficient, the file will obtain a second entry.
When the first byte of a pair equals FFH, the file has no more following blocks. The remaining byte pairs are
meaningless.
When the first byte of a pair equals FEH, the file has an additional entry in the directory. The second byte
indicates the location of the entry; the bits 0-4 show in which sector, and the bits 5-7 indicate which entry
within the sector.
Otherwise, the first byte shows in which lump the data block belonging to the file starts. Bits 5-7 in the second
byte then show, in which granule of this lump the data block starts, and the bits 0-4 indicate the length of the
data block (in granules).
An additional entry of a file can be recognised by bit 7 of byte 0. Whenever this bit is set to 1, then byte 1
indicates the location of the previous entry (see above). Bytes 2-12 stay unused, and the bytes 23-31 have the
same meaning as described above.
The separation of files into several data blocks may look somewhat complicated, but it allows to use of every
free granule on the floppy disk.
Deleting a file is done by setting the first byte of the file entry and the hash code to zero. The disk space
occupied by this file is then released. The data and all file entries remain unchanged.
3
3. File formats
This chapter gives an overview of the way that programs are stored on the floppy disk.
BASIC programs starts with a byte set to FFH. After that follows the program as it is stored in memory.
BASIC programs saved with the SAVE" ",A option, contain the ASCII characters, that are also shown by the
LIST command.
Pascal source files created with the Colour Pascal 2.0 compiler are also stored as a text file containing the
ASCII characters of the source file.
Machine language programs have a more complex format:
They are divided into blocks of 256 bytes maximum. Every block contains 4 extra bytes of load information:
Byte
1
2
3-4
Meaning
1 = Load data block.
2 = Last data block.
3 = Ignore data block.
Length+2: 2 means 256 bytes, 1 means 255 bytes, etc..
Load address of the data block
The last block of a file has only 4 bytes, 2 times 2 followed by the entry address of the program.
4
4. The File Control Block (FCB)
This chapter gives information about the FCB structure and the usage of an FCB.
To every opened file, a File Control Block is assigned. This FCB is the only connection to the file on the floppy
disk. The computer does not store if and how many files are opened, but installs a FCB. All operations use and
go through the FCB.
When using DOS routines, the address of the FCB used must be stored in register DE. Also, a buffer of 256
bytes is needed for every file, to read data into. The address of this buffer must be indicated when the file is
opened.
The programmer indicates, when opening a file, where the FCB is located in memory. This requires a 32 byte
memory area, that must be reserved for this purpose only.
Normally, DOS routines manage the FCB themselves; the programmer has just to call the right routines. It is
however possible, to change the FCB for own purposes. The meaning of the bytes inside the FCB are as
follows:
Byte 0:
Bit
7
6-2
1
0
Meaning when set
File opened
No meaning
File uses the complete floppy disk
Sectors are written protected (only DIR/SYS)
Byte 1:
Bit
7
6
5
4
3
2-0
Meaning when set
Always 0
System file
Buffer contains data of the next sector
Buffer contains data that still has to be written
Always set on the Colour Genie
Always 0 on the Colour Genie
Byte 2:
Byte 3-4:
Byte 5:
Byte 6:
Byte 7:
Byte 8:
Byte 9:
Bytes 10-11:
Bytes 12-21:
Bytes 22-23
Identical to byte 1 of the directory entry
Contain the address of the buffer
Indicates which byte of the current sector will be read/written next
Contains the used drive number
Contains the corresponding directory entry position
Identical to byte 3 of the directory entry
Contains the record length (0=256 bytes)
Indicate the current sector that is processed
Correspond with the bytes 20-29 of the directory entry
FFH, if the file has only one directory entry. Else, they indicate the location of the
second directory entry.
Correspond with the bytes 22-29 of the second directory entry (if present)
Bytes 24-31:
For the use of most DOS routines, the address of the used FCB must be loaded into register pair DE. After
returning, the zero flag is cleared in case no error occurred. If an error occurred, register A contains the error
number. The error code is identical to the DISK-Error messages.
5
5. DOS routines
A list of the DOS routines, with a short description will follow. First, the register values that are expected are
indicated. After that, the return values are given. If nothing else is mentioned, the routine will not change any
registers except AF.
File Open : CE24H
Entry:
DE
HL
B
in FCB
:
:
:
:
FCB address
Buffer address
Record length
Filename
Return:
AF
:
in FCB :
Error code
see FCB
This routine opens an existing file on the floppy disk. The filename in the FCB must follow the usual
conventions and must end with a 03 or 0DH. HL points to a buffer with a minimum size of 256 bytes.
Register B indicates the record length. This means how many bytes are processed at a read or write operation.
With B = 0, data are processed sector wise, so with 256 bytes at a time. All values from 0 to 255 are valid.
File Initialise : CE20H
Entry:
DE
HL
B
in FCB
:
:
:
:
FCB address
Buffer address
Record length
Filename
Return:
AF
:
in FCB :
Error code
see FCB
This routine is similar to the file open, which is called first. When the file however does not exist, the file is
created on the floppy disk. Therefor, this routine should only be used for write operations.
Read and write of single bytes.
For reading / writing single bytes, special easy to use routines are available. When opening the file, the record
length must be put into register B.
Read one byte : 0013H
Entry:
DE
:
FCB address
Return:
6
AF
:
Byte read, or error code when zero flag is clear.
Write one byte : 001BH
Entry:
DE
A
:
:
FCB address
Byte to be written
:
Error code
Return:
AF
Read one record : CE36H
Entry:
DE
HL
:
:
FCB address
When record length = 0 : buffer address
Return:
AF
:
in buffer:
Error code
Data read.
This routine reads one record. The record length is determined when the file is opened. If one works sector
wise, the sector that is read is stored in the buffer that is indicated when the file is opened. If the record length
= 0, the record is stored into a second buffer; register pair HL contains the address of this buffer.
Write on record : CE39H or CE3CH
Entry:
DE
HL
:
:
FCB address
When record length = 0 : buffer address
:
Error code
Return:
AF
This routine writes one record. The record length is determined when the file is opened. If one works sector
wise, the data must be present in the buffer that is indicated when the file is opened. Otherwise, the data must
be present in a second buffer; register pair HL contains the address of this buffer. Routine CE3CH also verifies
the data written.
File Close : CE28H
Entry:
DE
:
FCB address
:
Error code
Return:
AF
7
This routine closes a file a writes all necessary information onto the floppy disk. This routine must only be
called, when the file has changed due to write operations.
Random Access Routines.
The following routines enable you to change the NEXT pointer that determines which record has to be read or
written next.
Set NEXT to BC : CE42H
Entry:
DE
BC
:
:
FCB address
Record number
:
Error code
Return:
AF
This routine puts the NEXT pointer on the record indicated by the record number stored in register pair BC.
Set NEXT to 0 : CE3FH
Entry:
DE
:
FCB address
:
Error code
Return:
AF
This routine puts the NEXT pointer to the start of the file.
Set NEXT to EOF : CE48H
Entry:
DE
:
FCB address
:
Error code
Return:
AF
This routine puts the NEXT pointer to the end of file (only useful for writing).
Set NEXT to byte address : CE4EH
Entry:
DE
HLC
:
:
FCB address
Byte address
Return:
8
AF
:
Error code
This routine puts the NEXT pointer onto a byte, addressed by the 3 byte address stored into the registers HLC.
This routine is useful when working with the byte routines 0013H and 001BH.
Decrement NEXT : CE45H
Entry:
DE
:
FCB address
:
Error code
Return:
AF
This routine decrement the NEXT pointer; the record last processed is used again.
Check Filename and copy into FCB : CE1CH
Entry:
DE
HL
:
:
FCB address
Address of filename
:
Error code
Return:
AF
This routine checks the indicated filename. If it complies to the rules, it will copy it into the FCB so that the file
can be opened.
File Delete : CE2CH
Entry:
DE
:
FCB address
:
Error code
Return:
AF
This routine deleted the directory entry that belongs to the opened file.
Load Machine code program : CE30H
Entry:
DE
:
in FCB :
FCB address
Filename
Return:
AF
:
Error code
9
This routine opens the indicated file and loads the machine code program into memory.
Execute Machine code program : CE33H
Entry:
DE
:
in FCB :
FCB address
Filename
(does not return)
This routine opens the indicated file, loads the machine code program into memory and jumps to the entry
address when no error occurred. If an error occurred, a DISK-Error message is given.
Enter EOF into Directory : CE51H
Entry:
DE
:
FCB address
:
Error code
Return:
AF
This routine enters an end of file into the directory of the floppy disk.
The routines mentioned before make full usage of files from machine code programs possible. There are
however more routines available, that allow access to the floppy disk without using files. They should be used
with care, since a wrong usage can destroy data on the floppy disk.
Drive Select : CE5BH
Entry:
A
:
Drive number
:
Error code
Return:
AF
This routine selects the drive for the all following read/write operations.
Drive Test : CE5EH
Entry:
A
:
Drive number
:
Error code
Return:
AF
10
This routine selects the drive A and tests, whether the drive is ready and if a floppy disk is inserted.
Read Sector : CF6FH
Entry:
DE
HL
:
:
Sector number
Buffer address
Return:
AF
:
in buffer:
Error code
Data read
This routine reads one sector and stores the data in a buffer. The sector number is present in register pair DE;
the buffer address in register pair HL.
Test Sector : CF73H
Entry:
DE
:
Sector number
:
Error code
Return:
AF
This routine test if a sector can be read.
Write Sector : CF7FH
Entry:
DE
:
HL
:
in buffer:
Sector number
Buffer address
Data to be written
Return:
AF
:
Error code
This routine writes the data from a buffer to a floppy disk sector. The sector number is present in register pair
DE; the buffer address in register pair HL.
Write Protected Sector : CF7BH
Entry:
DE
:
HL
:
in buffer:
Sector number
Buffer address
Data to be written
Return:
11
AF
:
Error code
This routine writes the data from a buffer to a floppy disk sector. The sector number is present in register pair
DE; the buffer address in register pair HL. The sector is written with a mark. This normally only happens with
directory sectors. When such a sector is read, an error 6 occurs.
Re-select Drive : CE16H
Return:
AF
:
corrupted
This routine again selects the last selected drive.
Read Directory sector : D25FH
Entry:
A
:
Directory sector number
:
:
Error code
Buffer address (5900H)
Return:
AF
HL
This routine reads a directory sector (A contains the sector number) and stores it into the system buffer at
5900H.
Write Directory sector : D274H
Entry:
in system buffer : Data to be written
Return:
AF
HL
:
:
Error code
corrupted
This routine writes the directory sector last read back to the floppy disk.
One should take care using the write routines. A floppy disk with a damaged directory becomes unreadable in
most cases.
DOS also contains additional routines, that are not related to the usage of floppy disks, but can also be useful.
Issue Error Message : CE90H
Entry:
A
:
Error code
This routine generates a DISK-Error message and returns to BASIC.
12
Multiply : CE76H
Entry:
HL
A
:
:
Multiplicand
Multiplier
:
Result
Return:
AHL
This routine performs a multiplication. The result has a length of 3 bytes maximum.
Division : CE79H
Entry:
HL
A
:
:
Dividend
Divisor
:
:
:
Result
Fraction
corrupted
Return:
HL
A
BC
Give Time : CE6DH
Entry:
HL
:
Buffer address
Return:
in buffer:
BC
:
DE
:
HL
:
The time as an 8 byte string
corrupted
corrupted
corrupted
The time string uses the format hh:mm:ss.
Give Date : CE70H
Entry:
HL
:
Buffer address
Return:
in buffer:
BC
:
DE
:
HL
:
The date as an 8 byte string
corrupted
corrupted
corrupted
13
The date stored in the memory locations 4044H - 4046H is put in the buffer using the format dd.mm.yy
Insert Interrupt routine : CE10H
Entry:
DE
:
Address of the routine to be inserted
:
:
corrupted
corrupted
Return:
DE
HL
This routine inserts a program present in memory into the interrupt chain. This call has the same effect as the
CMD "Y address" statement in BASIC. The program must not already be a part of the interrupt chain! It may
not corrupt any Z80 register. This DOS call also executes a EI instruction.
Remove Interrupt routine : CE13H
Entry:
DE
:
Address of the routine to be removed
:
:
:
Corrupted
Corrupted
Corrupted
Return:
BC
DE
HL
This routine removes a program from the interrupt chain. This call has the same effect as the CMD"V address"
statement in BASIC. This DOS call also executes a EI instruction.
14
6. Interrupt routine format
On the Colour Genie, it is possible to insert routines in a so called interrupt chain. Every 25 milliseconds, the
computer walks through this chain and looks if routines should be executed.
A routine in this chain must have the following header:
Address
Description
xxxx+0,xxxx+1
xxxx+2
xxxx+3
xxxx+4
Vector to next interrupt routine (set by system)
Initial timer value
timer counter value
Entry address of the interrupt routine.
Inserting the routine is done from BASIC by using the CMD"Y xxxx" statement or by executing DOS call
CE10H with the address xxxx in register DE. The system then inserts it into the chain and stores the vector of
the next interrupt routine in the header. The address xxxx+2 contains a initial timer value.
The timer counter value at xxxx+3 is decremented every timer tick of 25 ms. When it reaches zero, the
interrupt routine is executed and the initial timer value on address xxxx+2 is copied to the timer counter value of
xxxx+3.
The address xxxx+4 is the entry address of the interrupt routine, here is where the executable code starts. The
routine must not corrupt any registers or the stack!
Note that the Z80 CPU must be in interrupt mode 1 (IM 1) to perform the executing of the interrupt chain.
15
7. Compatibility with TRS 80 / Video Genie Operating Systems
The most important routines in DOS are compatible with the corresponding routines of the most TRS80 / Video
Genie Operating Systems. The following routines are present in all these operating systems:
Colour Genie
TRS 80 / Video Genie
0013H
001BH
CE20H
CE24H
CE36H
CE39H
CE3CH
CE42H
CE28H
CE2CH
0013H
001BH
4420H
4424H
4436H
4439H
443CH
4442H
4428H
442CH
Other routines are not present in all operating systems. A routine that starts at CEXXH on the Colour Genie,
starts at 44XXH on the TRS 80 / Video Genie
The floppy disks are fully exchangeable. The formats for BASIC and machine code programs is identical.
16
8. Floppy disk formats
The Colour Genie DOS can handle the following floppy disks formats:
SS = Single Sided
DS = Double Sided
SD = Single Density
DD = Double Density
Sided
Density
Tracks
Sector/Track
Total Sectors
Capacity
SS
SS
SS
SS
DS
DS
DS
DS
SD
DD
SD
DD
SD
DD
SD
DD
40
40
80
80
40
40
80
80
10
18
10
18
20
36
20
36
400
720
800
1440
800
1440
1600
2880
102
184
204
368
204
368
408
736
In order to achieve the right format, the floppy disk drive has to be set to the proper drive type. This can be done
with the CMD"< drive# = Type" statement in BASIC. The drive# indicates for which of he 4 drives (0..3) the new
type applies. Default at start-up is drive type C.
Type
Floppy (Tracks)
Drive (Tracks)
Density
Sided
A
B
C
D
E
F
G
H
I
J
K
L
40
40
40
40
40
40
40
40
80
80
80
80
40
40
40
40
80
80
80
80
80
80
80
80
SD
SD
DD
DD
SD
SD
DD
DD
SD
SD
DD
DD
SS
DS
SS
DS
SS
DS
SS
DS
SS
DS
SS
DS
The types E, F, G and H are necessary for reading a 40 track floppy disk on a 80 track disk drive.
17
9. Reading alien floppy disks
It is possible for the Colour Genie to read floppy disks, that are made on the Genie I/II/III computers. Important
are the Pdrive (see G-DOS manual) correspond to the settings of the Colour Disk BASIC, since no adaptation
is possible from within the Colour Disk BASIC.
Following settings are required by the Colour Genie, so that alien floppy disks can be read:
Type
Type
Interface
Type
Drive
Units
In Block
Number Dir.
Units
Start Block
Directory
A
B
C
D
E
F
G
H
I
J
K
L
A
A
CK
CK
AL
AL
CKL
CKL
A
A
CK
CHK
A
C
E
G
A
C
E
G
A
C
E
G
2
4
3
6
2
4
3
6
2
4
3
6
2
4
3
6
2
4
3
6
2
4
3
6
20
20
24
24
20
20
24
24
40
40
48
48
Floppy disks, made on the Colour Genie, can be read on the Genie I/II/III using the Pdrive settings above. The
value for Start Block Directory however does not have to match.
Note that the Pdrive settings are not put on the floppy disks by the Colour Genie and a call of this table on a
Genie I/II/III causes an error.
18
Appendix A: Disk BASIC Memory usage.
Disk BASIC needs parts of the BASIC system memory (4000H - 43FFH) and parts of the normal memory from
5800H to 5C9AH, followed by the buffers (0-9) needed by files that are used by BASIC programs. Then the
memory for BASIC programs follows.
The following memory locations are important under DOS :
4040H
4041H
4042H
4043H
4044H - 4046H
4050H - 4056H
4057H - 405DH
405EH
4076H
407CH
408EH
43CEH
43E3H
43ECH
5800H
5900H
5A08H
5A0AH
5A71H
CEA0H
- 407DH
- 43E1H
- 43FFH
- 58FFH
- 59FFH
- 5A13H
- 5A98H
- CF17H
25 milliseconds counter for the time
Seconds counter
Minutes counter
Hours counter
Date
Interrupt routine for the time
Interrupt routine for displaying the time
Number of last read directory sector (for write
routine at D274H)
Hash code of the last opened file
Entry address for a program loaded with CMD"L"
Number of files in Disk BASIC
Disk BASIC FCB addresses (2 byte pairs)
Error code of last reported Disk Error
USR functions entry addresses (2 bytes pairs)
Buffer for Close and Kill
System buffer for reading of directory
Actual drive number
Actual drive data
Data for drives 0 - 3
Data for drive types A - L
Drive data are loaded from EPROM to 5A71H - 5A98H when a CMD"<" statement is executed. When a drive is
selected, the drive data of the selected drive is copied to 5A0AH - 5A13H. This data block has to following
contents :
5A0AH
5A0BH
5A0CH
5A0DH
5A0EH
5A0FH
5A10H
5A11H
5A12H
5A13H
Number of first lump belonging to directory
Number of lumps on floppy disk
Stepper motor speed: 7 for SD, 53H for DD
Number of tracks (40/80)
Number of sectors per track
Number of granules per lump
Always 0
Flags used for control of floppy disk controller
Number of sectors per granule (always 5)
Directory length in granules
19
Appendix B: Memory map
Hex
Decimal
Peek/Poke
FFFF
65535
-1
FC00
64512
-1024
FBFF
64511
-1025
F800
63488
-2048
F7FF
63487
-2049
F400
62464
-3072
F3FF
62463
-3073
F000
61440
-4096
EFFF
61439
-4097
E000
57344
-8192
DFFF
57343
-8193
CF00
52992
-12544
CEFF
52991
-12545
CE00
52736
-12800
CDFF
52735
-12801
C000
49152
-16384
BFFF
49151
-16385
8000
32768
-32768
7FFF
32767
32767
6000
24576
24576
5FFF
24575
24575
5A00
23040
23040
59FF
23039
23039
5900
22784
22784
58FF
22783
22783
5800
22528
22528
57FF
22527
22527
4800
18432
18432
47FF
18431
18431
4400
17408
17408
43FF
17407
17407
4000
16384
16384
3FFF
16383
16383
0000
0
0
ROM Cartridge (1 KB)
Keyboard Matrix (1 KB)
User-definable Characters (1 KB)
Character Colour Memory (1 KB)
DOS Utilities (4 KB)
DOS Routines (4¼ KB)
DOS Vectors (¼ KB)
BASIC Vectors (3½ KB)
User RAM (EG 2011) (16 KB)
User RAM (8 KB)
Program Buffers 1 to 3 (1 at lowest address) (1½ KB)
I/O Buffer (DOS) (¼ KB)
Floppy Disk Buffer (¼ KB)
Graphic Screen Memory (4 KB)
Text Screen Memory (1 KB)
Vectors, Marks and System Variables (DOS and BASIC) (1 KB)
BASIC Interpreter (EPROM) (16 KB)
20
Appendix C: Error codes
The following table contains the error codes and their meaning. This table is also valid for the G-DOS operating
system (Genie I/II/III) and contains therefor some error codes that can not occur under the Colour Disk BASIC.
Code
Decimal Hex
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D
0E
0F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
20
21
22
23
24
25
26
27
28
29
2A
2B
2C
2D
2E
2F
Error description
No error
Bad file data
Read error: search error
Read error: data lost
Read error: checksum error
Read error: record not found
Read error: trying to read protected sectors
Read error: trying to read system sectors
Device unreachable
Undefined error code
Write error: search error
Write error: data lost
Write error: checksum error
Write error: record not found
Write error on disk drive
Floppy disk is write protected
Peripheral device unreachable
Directory read error
Directory write error
Illegal filename
Track number too high
Illegal DOS call function
Undefined error code
Undefined error code
File not in directory
Access denied by file
Directory full
Floppy disk full
End of file reached
Beyond end of file
Directory full: cannot extend file
File not found
Illegal or missing disk drive
No device reachable
Load error: bad format
Memory error
Try to load in ROM
Load error: access denied
File not open
Illegal initialisation data on floppy disk
Illegal track number
Illegal logical filenumber
Illegal DOS function
Illegal function under chaining
Directory incorrect
Bad FCB data
System program not found
Bad parameter
21
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
No filename
Bad floppy disk type
Read error BOOT
Fatal DOS error
Illegal abbreviation, separator or end marker
File already exists
Command too long
Access denied by floppy disk
Not a Mini-DOS function
Forced termination of function
Difference at verify
Insufficient memory
Incompatible drive or floppy disk
ADE=N attribute, cannot extend file
Cannot extend file at read
22
Appendix D: System Entry Table
Address
Name
Description
CE00H
CE05H
CE08H
CE09H
CE0DH
CE10H
CE13H
CE16H
CE19H
CE1CH
CE20H
CE24H
CE28H
CE2CH
CE30H
CE33H
CE36H
CE39H
CE3CH
CE3FH
CE42H
CE45H
CE48H
CE4BH
CE4EH
CE51H
CE54H
CE5BH
CE5EH
CE67H
CE6AH
CE6DH
CE70H
CE76H
CE79H
CE79H
CE80H
$DOS
$DOSCMD
$NERROR
$DERROR
$DEBUG
$ENQUE
$DEQUE
$RESEL
$DOSCAL
$EXFIL
$INIT
$OPEN
$CLOSE
$KILL
$LOAD
$RUN
$RDSEC
$WRSEC
$WRSECV
$POS0
$POSBC
$POSDEC
$POSEOF
$ALLOC
$POSBRA
$WREOF
$DELIM
$DRVSEL
$DSKMNT
$PRINT
$LPRINT
$CONTIM
$CONDAT
$MULT
$DIV
$HEXDE
DOSFCB
Return to command mode
Calls machine code program or DOS command
RET Z, else
Report error message
Call system monitor
Insert interrupt routine
Remove interrupt routine
Reselect current disk drive
as $DOSCMD, but returns
Examine and transfer filename into FCB
Initialises file and opens FCB
Opens FCB for current file
Closes FCB
Deletes file entry
Loads machine code program
Runs machine code program
Reads sector
Writes sector
Writes and verifies sector
Set FCB sector number to zero
Set FCB sector number to (BC)
Decrements FCB sector number
Sets FCB sector number at end of file
Reserves unit on floppy disk for file
Positions FCB at relative byte address
Write end of file into directory
Tests delimiters at parameters
Selects disk drive
Tests if floppy disk in drive
Prints text on screen
Prints text on printer
Gives time as 8 bytes string
Gives date as 8 bytes string
Multiply A*HL=AHL
Divides HL div A=HL mod A
Gives hexadecimal representation of DE
System internal FCB of 32 byte length
23
Appendix E: Description of the Restart commands
The Restart commands (RST) are subroutines in Z80 machine language (like CALL routines). The advantage of
RST commands is that they use little memory. A CALL command uses 3 bytes; a RST command uses only 1
byte. The following routines are used as subroutines in Colour Disk BASIC:
RST 00
Jumps to memory location 0 and corresponds with a cold boot
RST 08
Syntax check
The memory address that is addressed by HL is compared to the byte following the RST 08. If
they are equal, a RST 10 is executed, else a syntax error is reported.
RST 10
Loads the memory location addressed by HL+1 into the accumulator A.
Blanks and Linefeeds are skipped. Digits cause the setting of the Carry-flag, a ':' or a 00 cause
the setting of the Zero-flag
RST 18
Compares HL with DE register pair
HL > DE:
Zero-flag=0,
Carry-flag=0
HL = DE:
Zero-flag=1,
Carry-flag=0
HL < DE:
Zero-flag=0,
Carry-flag=1
RST 20
Tests the type of the contents of the X-register stored at address
Integer:
Zero-flag=0,
Carry-flag=1,
Parity-Flag=1,
Single:
Zero-flag=0,
Carry-flag=1,
Parity-Flag=0,
Double:
Zero-flag=0,
Carry-flag=0,
Parity-Flag=1,
String:
Zero-flag=1,
Carry-flag=1,
Parity-Flag=1,
RST 28
Used to load a system module. The Accumulator A contains the loader
code. RST 28 is also called when pressing the BREAK key.
RST 30
Generally used to call a DEBUG program. It returns after termination of the
DEBUG program.
RST 38
This routine is executed every 25 milliseconds if the Z80 CPU is set to
interrupt mode 1 (IM 1)
40AFH.
Sign-Flag=1
Sign-Flag=0
Sign-Flag=0
Sign-Flag=0
24
Appendix F: Vector tables for DOS / Disk BASIC
The system variable space between 4000H and 43FFH contains the vectors for the Disk BASIC statements and
the vectors into DOS. Every vectors requires 3 bytes (space necessary for a absolute jump instruction).
The first table occupies the area from 4152H to 41A5H. It contains the vectors for the Disk BASIC statements.
Under Level II BASIC, these vectors all contain a jump to 013BH in the BASIC interpreter ROM area. Under
Disk BASIC, the vectors contain a jump to the following addresses:
Address (Dec, Hex)
Jump to:
Statement
16722
16725
16728
16731
16734
16737
16740
16743
16746
16749
16752
16755
16758
16761
16764
16767
16770
16773
16776
16779
16782
16785
16788
16791
16794
16797
16800
16803
C565H
C3AEH
C562H
C353H
C55FH
CA25H
CA04H
C9FFH
C54EH
C54BH
C548H
C2FBH
C24DH
CB5CH
C5D0H
CAA1H
CAA0H
C9C4H
C8D6H
C962H
CC0EH
CBEBH
1E4AH
C57EH
C57FH
C456H
C99CH
C65BH
CVI
FN
CVS
DEF
CVD
EOF
LOC
LOF
MKI$
MKS$
MKD$
CMD
TIME$
OPEN
FIELD
GET
PUT
CLOSE
LOAD
MERGE
NAME
KILL
none (Previous &)
LSET
RSET
INSTR
SAVE
LINE
4152H
4155H
4158H
415BH
415EH
4161H
4164H
4167H
416AH
416DH
4170H
4173H
4176H
4179H
417CH
417FH
4182H
4185H
4188H
418BH
418EH
4191H
4194H
4197H
417AH
419DH
41A0H
41A3H
25
The second table contains the BASIC vectors into DOS. Under Level II BASIC, these vectors contain a return
instruction followed by 2 nops to fill the remaining 2 bytes memory space reserved for each vector. Under Disk
BASIC, the vectors contain a jump to the following addresses:
Address (Dec, Hex)
Jump to:
Description
16806
16809
16812
16815
16818
16821
16824
16827
16830
16833
16836
16839
16842
16845
16848
16851
16854
16857
16860
16863
16866
C1D3H
C390H
C959H
C6BBH
C98BH
C75FH
C76EH
C9F5H
C685H
C6F2H
C701H
C8D3H
C62AH
C77CH
C77BH
C747H
C68DH
C4DAH
C7C2H
C6A5H
CC16H
Error routine
USR
Return to active command mode
Input line
After tokenizing
After accepting a new program line
After accepting a new program line
Clear after cleaning all variables
After ending printer output
Character output
Keyboard read at program execution
RUN
PRINT
PRINT (numeric value)
Start of a new program line
PRINT or PRINTTAB
INPUT
MID$ left of = sign
Data processing after READ / INPUT
Termination of INPUT
SYSTEM
41A6H
41A9H
41ACH
41AFH
41B2H
41B5H
41B8H
41BBH
41BEH
41C1H
41C4H
41C7H
41CAH
41CDH
41D0H
41D3H
41D6H
41D9H
41DCH
41DFH
41E2H
26
Appendix G: Program examples
Error report with return to program:
ERROR
TEXT1
PUSH
PUSH
CALL
CALL
LD
CALL
POP
LD
LD
CALL
CALL
POP
OR
RET
DEFM
DEFB
HL
AF
2169H
20F9H
HL,TEXT1
2B75H
AF
L,A
H,0
0FAFH
20FEH
HL
FFH
;Output to screen
;Cursor to start of line
;Output text
;Error code to HL
;Output HL
;Output CR
;Clear Z flag
'Disk-Error '
0
Open file with request for filename (ROPEN for read, WOPEN for write):
TEXT2
OPEN
ROPEN
WOPEN
DEFM
DEFB
LD
CALL
PUSH
LD
LD
CALL
LD
LD
PUSH
ADD
LD
POP
LD
CALL
CALL
POP
JR
LD
CALL
RET
CP
CALL
JR
OR
RET
CALL
RET
CALL
JR
CALL
JR
CALL
RET
'Filename: '
0
HL,TEXT2
2B75H
;Output text
BC
;Save record length
HL,5B08H
;Buffer address
B,18H
;Maximum length of input
5D9H
;Input filename
C,B
B,0
HL
HL,BC
(HL),0
;End marker
HL
DE,FCB
;FCB address
0CE1CH
;Copy filename
NZ,ERROR
;Call if error
BC
;Restore record length
NZ,OPEN
;Input new filename
HL,BUFFER
;256 bytes buffer
0CE24H
;Open file
Z
;If no error return
18H
;Test error code
NZ,ERROR
;Report error
NZ,OPEN
;Enter new filename
A
;File not found
OPEN
Z
ERROR
ROPEN
OPEN
Z,EXI
0D694H
Z
;Open file
;If no error return
;Report error
;Try again
;Open file
;If file already exists jump
;Create file
;If no error return
27
EXI
TEXT3
CALL
JR
LD
CALL
CALL
CP
RET
JR
DEFM
DEFB
DEFM
DEFW
ERROR
;Report error
WOPEN
;Try again
HL,TEXT3
2B75H
;Ouput text
384H
;Wait for key pressed
'Y'
Z
;If file may be used return
WOPEN
;Try again
'File already exists.'
0DH
'Use anyway?'
0DH
LD
CALL
CALL
JP
RET
DE,FCB
0CE28H
NZ,ERROR
NZ,PROG
;FCB address
;Close file
;If failure report error
;And jump to start of program
PUSH
PUSH
LD
CALL
CALL
JR
POP
POP
RET
DE
AF
DE,FCB
1BH
NZ,ERROR
NZ,PROG
AF
DE
;Save registers
Close file:
CLOSE
Write byte:
WBYTE
;FCB address
;Write byte
Read byte (Carry flag is set at end of file):
RBYTE
NOERR
EOF
PUSH
LD
CALL
JR
CP
CALL
JP
SCF
JR
OR
POP
RET
DE
DE,FCB
13H
Z,NOERR
1CH
NZ,ERROR
NZ,PROG
EOF
A
DE
;Save register
;Read byte
;If no error jump
;EOF code
;If not EOF report error
;Clear carry flag
Write a memory block from BSTART to BEND:
SAVE
LOOP
LD
CALL
LD
LD
INC
LD
CALL
RST
B,0
WOPEN
HL,BSTART-1
DE,BEND
HL
A,(HL)
WBYTE
18H
;Sector operation
;Open file
;Byte into A
;Write byte
;Compare HL and DE
28
JR
JP
NZ,LOOP
CLOSE
;Loop if not equal
;Close file
LD
CALL
LD
LD
CALL
RET
LD
INC
JR
B,0
ROPEN
HL,BSTART
DE,BEND
RBYTE
C
(HL),A
HL
LOOP1
;Sector operation
;Open file
Load a memory block:
LOAD
LOOP1
;Read byte
;If EOF then return
;Store byte
;Next byte
The next two routines make it possible to use an opened file as a memory of 64 KByte at maximum. READ
corresponds with LD A,(HL) and WRITE corresponds with LD (HL),A .
SETPOS
READ
WRITE
PUSH
PUSH
LD
LD
LD
CALL
POP
POP
RET
CALL
JR
CALL
JR
BC
HL
C,L
L,H
H,0
0CE4EH
HL
BC
SETPOS
RBYTE
SETPOS
WBYTE
;Address to HLC
;Set position
;Set position
;Read byte to A
;Set position
;Write byte
Write records that contain a maximum of 20 characters, read from the keyboard:
WRITE1
LOOP2
LD
CALL
LD
LD
PUSH
CALL
POP
JP
LD
CALL
CALL
JP
JR
B,20
WOPEN
HL,BUFFE1
B,20
HL
5D9H
HL
C,CLOSE
DE,FCB
0CE39H
NZ,ERROR
NZ,PROG
LOOP2
;Record length
;Open file
;20 byte buffer
;Maximum length
;Input from keyboard into buffer
;If BREAK key pressed jump
;FCB address
;Write record
;Next record
Read the fifth record of the file created above:
READ1
LD
CALL
LD
LD
CALL
CALL
JP
LD
B,20
ROPEN
DE,FCB
BC,4
0CE42H
NZ,ERROR
NZ,PROG
HL,BUFFE1
;Record length
;Open file
;FCB address
;Number of fifth record
;Set position
;20 byte buffer
29
CALL
CALL
JP
RET
0CE36H
NZ,ERROR
NZ,PROG
;Read record
Calculate the sector number of the first directory sector of the floppy disk in drive 0:
CALC
LD
CALL
CALL
JP
LD
LD
CALL
CALL
JP
LD
LD
LD
LD
CALL
LD
CALL
RET
A,0
;Drive number
0CE5EH
;Test drive
NZ,ERROR
NZ,PROG
HL,0
;Sector number
DE;BUFFE2
;256 byte buffer
0CF6FH
;Read sector 0
NZ,ERROR
NZ,PROG
A,(BUFFE2+2);Third byte into A
L,A
H,0
A,(5A0FH)
;Granules per lump
0CE76H
;Multiplication
A,(5A12H)
;Sectors per granule
0CE76H
;Multiplication
;Result in HL
Calculate the number of free granules of the floppy disk in drive 0:
CALC1
LOOP3
LOOP4
NTFREE
LD
CALL
CALL
JP
XOR
CALL
CALL
JP
LD
LD
LD
LD
LD
LD
LD
LD
RRA
JR
INC
DJNZ
INC
DEC
JR
RET
A,0
0CE5EH
NZ,ERROR
NZ,PROG
A
0D25FH
NZ,ERROR
NZ,PROG
IX,0
A,(5A0FH)
D,A
A,(5A0BH)
E,A
HL,5900H
A,(HL)
B,D
C,NTFREE
IX
LOOP4
HL
E
NZ,LOOP3
;Drive number
;Test drive
;A=0
;Read directory sector 0
;Set counter on 0
;Granules per lump
;Lumps on the floppy disk
;Address of system buffer
;Read byte into A
;Bit 0 into carry
;If granule not free jump
;Increment counter
;Next byte
;Loop for every lump
;Result in IX
Change the name of the floppy disk:
NEWNAM
LD
CALL
CALL
JP
A,0
0CE5EH
NZ,ERROR
NZ,PROG
;Drive number
;Test drive
30
XOR
CALL
CALL
JP
LD
A
0D25FH
NZ,ERROR
NZ,PROG
DE,59D0H
LD
LD
LDIR
CALL
HL,NAME
BC,8
CALL
JP
RET
NZ,ERROR
NZ,PROG
0D274H
;Read directory sector 0
;Address of floppy disk name in
;buffer
;Address of the new name
;Length of the name
;Replace old with new name
;Write directory sector 0 back to
;the floppy disk
Insertion of an interrupt routine (the routine beeps every 2 seconds):
PING
INT
LD
PUSH
CALL
DE,INT
DE
0CE13H
POP
CALL
RET
DEFW
DE
0CE10H
DEFB
80
DEFB
PUSH
PUSH
PUSH
PUSH
CALL
POP
POP
POP
POP
RET
80
AF
BC
DE
HL
357CH
HL
DE
BC
AF
0
;Address of interrupt routine
;Just to be safe the routine is
;first removed from
;the interrupt chain
;Insert interrupt routine
;Storage space for interrupt
;vector
;Starting value for counter
;80*25ms
;Counter
;Save registers
;Beep
;Restore registers
31
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement