Last modified on 13 April 2024, at 04:49

AMSDOS Memory Map

AMSDOS uses two memory blocks. The first is always at BE40h..BE7Fh (on the 464 this region was used as Stack). The second is allocated from User RAM, typically located at A700h..ABFFh (unless other expansion ROMs with higher ROM bank number have already allocated RAM at that locations).

AMSDOS RAM 1 (always at BE40h..BE7Fh)

 BE40   2 Pointer to CP/M DPH for Drive A and drive B  (A910h) (CPM:AE58h) (see below)
 BE42   2 Pointer to XPDB for Drive A and drive B      (A890h) (CPM:ADD8h)
 BE44   2 Delay for Motor Spin-up in 1/50 seconds      (0032h)
 BE46   2 Delay for Motor Spin-down in 1/50 seconds    (00FAh)
 BE48   1 Delay for Formatting in whatever units       (AFh)
 BE49   1 Delay for whatever in milliseconds           (0Fh)
 BE4A   1 Delay for Track-Settle in milliseconds       (0Ch)
 BE4B   1 Number of bytes received in Result Phase
 BE4C   7 Response from FDC in Result Phase
 BE53   1 Drive HS/US
 BE54   1 Track
 BE55   1 Record
 BE56   1 Drive HS/US
 BE57   1 Track
 BE58   1 Sector
 BE59   1 Number of Records per Track? or (Blockmask+1)?
 BE5A   1 Drive HS/US
 BE5B   1 Track
 BE5C   1 Record
 BE5D   1 ?
 BE5E   1 Flag Read/Write Sector
 BE5F   1 Flag On/Off Motor
 BE60   2 Pointer to 128-byte Directory Record I/O Buffer (A930h) (CPM:0080h)
 BE62   2 Pointer to 512-byte Sector I/O Buffer           (A9B0h) (CPM:AEF8h)
 BE64   2 Stack...Temporary...?                           (BFxxh)
 BE66   1 Number of retries (10h)
 BE67   6 Ticker Block (Chain,Count,Reload)
 BE6D   7 Event Block (Chain,Count,Class,Proc,Bank)
 BE74   1 Desired Track or Sector Number
 BE75   1 FDC Command Number
 BE76   2 Pointer to 512-byte Sector I/O Buffer           (A9B0h) (CPM:AEF8h)
 BE78   1 Flag Enable/Disable Error Messages
 BE79   1 Reserved, CPC+: 00h=Normal, FFh=Enable Keyboard Scanning during I/O
 BE7A   1 Reserved, CPC+: 00h=No Disc (464+), FFh=Disc (6128+)
 BE7B   2 Reserved
 BE7D   2 Pointer to Memory Pool                          (A700h) (CPM:N/A)
 BE7F   1 Hook                                            (C9h)

AMSDOS RAM 2 (usually at A6FCh..ABFFh)

 A6FC   4 AMSDOS RSX Block (Next block, AMSDOS ROM bank) (0000h,0007h)
 A700   1 Default Drive (00h or 01h)
 A701   1 Default User  (00h and up)
 A702   1 Active Drive  (00h or 01h)
 A703   2 Pointer to DPH for Active Drive (A910h or A920h)
 A705   1 Flag if OPEN on Default Drive
 A706   2 Stackpointer
 A708  36 Extended File Control Block for OPENIN
 A72C  36 Extended File Control Block for OPENOUT
 A750  74 File Header for OPENIN
 A79A  74 File Header for OPENOUT
 A7E4 128 Temporary Record & Filename Buffer
 A864  39 Original CAS_Function Vectors (13 x 3 bytes)
 A88B   3 FAR Address for RST4 in patched CAS_vectors
 A88E   2 ?
 A890  64 Extended Disk Parameter Block Drive A
 A8D0  64 Extended Disk Parameter Block Drive B
 A910  16 Disk Parameter Header Drive A
 A920  16 Disk Parameter Header Drive B
 A930 128 Record Buffer for Directory Records
 A9B0 512 Sector Buffer
 ABB0  80 Reserved

Extended File Control Block (FCB) for OPENIN/OPENOUT

 00h  1 Drive Number (00h=A, 01h=B, FFh=Not Open)
 01h  1 User Number
 02h  8 Filename  (padded with 20h)
 0Ah  3 Extension (padded with 20h)
 0Dh  1 Extent Number (00h=First directory entry of file)
 0Eh  2 Zero
 10h  1 Number of Records in current Extent
 11h 16 Block Numbers for current Extent
 21h  3 Number of previously accessed Records

File Header for OPENIN/OPENOUT

 00h  1 Access Mode (1=CHAR, 2=DIRECT)
 01h  2 Pointer to 2K work buffer
 03h  2 Pointer to current CHAR in 2K work buffer
 05h 16 User Number and Filename (padded with 00h)
 15h  1 Block Number (whatever, can be zero)
 16h  1 Last Block   (whatever, can be zero)
 17h  1 File Type    (00h=Basic, 01h=EncryptedBasic, 02h=Binary)
 18h  2 Data Length  (whatever, can be zero)
 1Ah  2 Load Address in memory
 1Ch  1 First Block           FFh
 1Dh  2 Filesize (excluding the 80h-byte header)
 1Fh  2 Entrypoint (for executable binary files)
 21h 36 Unused (free for user?) (parts are used for OPENOUT)
 45h  3 24bit Filepos in CHARs, or 16bit Filesize if non-ASCII file
 48h  2 Checksum accross [05h..47h]

Disk Parameter Header (DPH) for Drive A/B

 00h  2 XLT    Skew Factor Translation (physical-to-logical sector) (not used)
 02h  2 TRACK  Current Track (misused as DIRNUM by AMSDOS)
 04h  2 SECTOR Current Sector
 06h  2 DIRNUM Current Directory Number
 08h  2 DIRBUF Pointer to Directory Buffer (A930h)
 0Ah  2 DPB    Pointer to DPB/XDPB (A890h/A8D0h for Drive A/B) Drive Param Block
 0Ch  2 CSV    Pointer to CSA (A8A9h/A8E9h for Drive A/B) Checksums
 0Eh  2 ALV    Pointer to ALT (A8B9h/A8F9h for Drive A/B) Allocation Table

Extended Disk Parameter Block (XDPB,CSA,ALT) for Drive A/B

 00h  2 SPT   Records per Track (CPM/Data=36, IBM=32)
 02h  1 BSH   Block Shift (3) (records per block = 1 SHL N)
 03h  1 BLM   Block Mask  (7) (records per block minus 1)
 04h  1 EXM   Extend Mask (0)
 05h  2 DSM   Max Block Number  (CPM=170, Data=179, IBM=155)
 07h  2 DRM   Max Dir Entries-1 (63)
 09h  2 AL    Directory Allocation Table (11000000b,00000000b = Block 0,1)
 0Bh  2 CKS   Check Area Size (Size of the "CSA" field) (0010h)
 0Dh  2 OFF   Track Offset (Size of Bootstrap) (CPM=2, Data=0, IBM=1)
 0Fh  1 FSC   First Sector on Track (CPM=41h, Data=C1h, IBM=01h)
 10h  1 PST   Physical Sectors per Track (CPM/Data=9, IBM=8)
 11h  1 GPS   GAP3 for Sector Read/Write (2Ah)
 12h  1 GPT   GAP3 for Track Formatting  (52h)
 13h  1 FLB   Fillbyte for Track Formatting (E5h)
 14h  1 BPS   Bytes per Sector (2=512) (80h SHL N, Shift amount or so?)
 15h  1 RPS   Records per Sector (4)
 16h  1 Current Track
 17h  1 Recalibrate Track 0 Flag
 18h  1 Flag Login on any access ? (re-detect CPM/Data format?)
 19h 16 CSA   Checksums (directory record chksums, for sensing disk-changes)
 29h 23 ALT   Block Allocation Table (23x8bit = 184bit) (only 180bit used)

Finding the XDPB for a drive

The 2 byte pointer at &BE40 points to a list of DPH structures, 1 per drive, listed in order. In most AMSTRAD dos there is space for 2 only.

To get the XDPB for a drive (this works on VDOS, X-DDOS, AMSDOS and ParaDOS:

  ;; A = drive
  ld l,a 
  ld h,0
  add hl,hl
  add hl,hl
  add hl,hl
  add hl,hl
  ld de,(&be40)
  add hl,de
  ld de,&A
  add hl,de
  ld a,(hl)
  inc hl
  ld h,(hl)
  ld l,a
  ;; HL = address of XDPB

On VDOS, to access the XDPB for the 3rd drive, you need to use |S,1:|A and then read it.

On Dobbertin HD and Vortex HD you can't get the XDPB for the hard disc partitions using the above code.