CpcAlive is a
programming
environment
Amstrad CPC

compatible
for graphics
 animations
creation.







Cpc Online

Cpc basic key words
( English - Español )

Cpc basic error messages

The memory

The Cpc system vectors

Diskettes management

Z80 processor opcodes and
operation

CpcAlive installer for
Windows and DosBox



CpcAlive Documentation

SmallAsm is a Z80 assembler
for Dos









Cpc 6128 - Documentation



The memory


Last review:
V1.16 - 16/12/2014 - Z80 assembler correction
V1.15 - 30/11/2014 - corrections
V1.14 - 20/11/2014 - display ASM sources in Z80 debugger

The 6128 has a 128 KB memory (RAM) divided into eight blocks containing 16 KB each one, numbered from 0 to 7. Only four blocks can beings connected simultaneously.

Value on port &7F    blocks position
                &C0            0,1,2,3            <
standard Cpc configuration memory
                &C1            0,1,2,7
                &C2            4,5,6,7
                &C3            0,3,2,7
                &C4            0,4,2,3
                &C5            0,5,2,3
                &C6            0,6,2,3
                &C7            0,7,2,3

The Cpc system exploits only the first configuration. In this configuration, block 0 occupies memory space 0 to 03FFFh, block 1 space 04000h to 07FFFh, block 2 space 08000h to 0BFFFh and block 3 space 0C000h to 0FFFFh.The screen exploits block 3. The higher part of block 2 contains the system variables. The lower part of block 0 is used by the system. BASIC programs are loaded by the system starting from address 0170h. Binary datas can beings loaded starting from the address defined with the Basic instruction "MEMORY". If datas are executable programs, they could be called with the instruction "CALL".

There is three 16Kb roms blocks in the Cpc 6128 (48Kb). One of these blocks contains the operating system which is connected in zone 0 to 03FFFh (lower rom). The two other blocks (BASIC and DISC system) are connected in zone 0C000h to 0FFFFh (higher roms). The system can exploit in this zone 252 blocks (16Kb each one). An interesting characteristic of these roms is that they can receive BASIC programmable instructions (Resident System eXtension).

Amstrad Cpc Rom code sample with programmable basic instructions (Resident System eXtension)

The system memory map



Basic error messages

1     Unexpected NEXT
2     Syntax error
3     Unexpected RETURN
4     DATA exhausted
5     Improper argument
6     Overflow
7     Memory full
8     Line does not exist
9     Subscript out of range
10     Array already dimensionned
11     Division by zero
12     Invalid direct command
13    Type mismatch
14     String space full
15     String too long
16     String expression too complex
17     Cannot continue
18     Unknown user function
19     RESUME missing
20     Unexpected RESUME
21     Direct command found
22     Operand missing
23     line too long
24     EOF met
25     File type error
26     NEXT missing
27     File already open
28    Unknown command
29     WEND missing
30     Unexpected WEND
31     File not open
(See 
«Diskette errors»)
32     Broken in
(See «Diskette errors»)




Diskettes management

AMSDOS is a BASIC AMSTRAD extension, adding additional external commands and redefining some existing instructions. The new external commands are identified with the symbol | (vertical bar).

Names and types of AMSDOS files
The name consists of two parts separated by a point, the first part is 8 letters large maximum and the second is 3 letters large. The second part represents the file type indicator. File names and their indicators can be composed with a mixture of letters and numbers, but can't contain spaces, nor punctuation marks. The file type indicator, simple convention indicating the type of the file, does not do any precise part, the system distinguishing the files between them with a particular header. If extension is not specified at the time of a safeguard, AMSDOS determines which extension to allot with the following way:

.<space>    Standard not specified. Perhaps a data file created by the command OPENOUT"<nomfich>" (file name) or a BASIC program safeguarded by using a command like SAVE"<nomfich>",A

.BAS
        Programs BASIC safeguarded using commands like SAVE"<nomfich>" or SAVE"<nomfich>",P

.BIN
        Programs or storage area safeguarded by a command like SAVE"<nomfich>",B (<binary parameters>)

.BAK
       Old version of a file safeguarded by AMSDOS. The user can thus recover the old version if he need it.


Principals AMSDOS external commands

|A
Direct the inputs/outputs towards unit A. Equivalent to |DRIVE with A for parameter.


|B
Direct the inputs/outputs towards unit B. Equivalent to |DRIVE with B for parameter.

|CPM
Load and initializes the operating system contained in the diskette system.

|DIR
Display the catalogue of the diskette and space available.

|DRIVE,<alphanumeric chain>
ex: |DRIVE,"A"

Direct the inputs/outputs towards one of the units.

|ERA,<alphanumeric chain>
ex: |ERA,"*.BAS"
Erase all files which correspond to this file name and wich are not in Writing only. Jokers are allowed.

|REN,<alphanumeric chain>,<alphanumeric chain>
ex: |REN,"NEW.BAS","OLD.BAS"

Rename a file. Jokers are not allowed


Diskette errors

Several errors can occur at the time of the
filing operations treatment. Although the BASIC gathers them under the number of ERRor 32, you can obtain further information by calling the function DERR. Here is the significance of the values which it returns:

AMSDOS error      DERR value

0                            0 ou 22                 [ESC] activation
14                          142 (128+14)         Channel state not valid
15                          143 (128+15)         End of file (hardware)
16                          144 (128+16)         Bad command, generaly incorrect file name
17                          145 (128+17)         File allready exist
18                          146 (128+18)         File don't exist
19                          147 (128+19)         Catalogue saturated
20                          148 (128+20)         Diskette full
21                          149 (128+21)         Change of the diskette with open files
22                          150
(128+22)         File read only
26                          154 (128+26)         End of file (software)


If AMSDOS already brought back an error, the bit 7 took value 1, shifting that of DERR of 128.

The other values reported by DERR come from the diskette controller, the bit 6 being always ON. The Bit 7 indicates if AMSDOS brought back the error or not (see above). Here is the significance of each bit:


Bit        Significance
0           Missing adress
1           Impossible writing. Protected diskette.
2           No data. Sector can't be found.
3           Unity not ready. No diskette in unity.
4           Overload
5           Data error. Cyclic Redundancy Check error
6           Alway set to indicate an error wich come from the diskette controller.
7           Set if AMSDOS already brought back the error.



The keyboard