CODINGDDI-1 Firmware: The Complete CPC 464 DISC Operating System ROM Specification

DDI-1 Firmware: Chapter 2 - CP/M 2.2 and the BIOS (3/3)
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Chapter 2 - CP/M 2.2 and the BIOS

2.15 Extended Disc Parameter Blocks

In order to facilitate reading and writing ‘foreign' discs of differing formats, all the parameters concerning a drive are kept in RAM in an extended CP/M disc parameter block (XPB). The knowledgeable user may patch an XPB.

There are two XPBs, one per drive.

XPB structure:

  • bytes 0..14 : standard CP/M DPB.
  • byte 15 : first sector number.
  • byte 16 : number of sectors per track.
  • byte 17 : gap length (read/write).
  • byte 18 : gap length (format).
  • byte 19 : filler byte for formatting.
  • byte 20 : log2 (sector size) - 7, 'N' for µPD765A.
  • byte 21 : sector size /128 (must be a power of 2).
  • byte 22 : reserved: current track (set by BIOS).
  • byte 23 : reserved: # 00 ⇒ not aligned, #FF ⇒ aligned (set by BIOS).
  • byte 24 : # 00 ⇒ auto-select format, # FF ⇒ don't auto-select format.

To find the XPB for a particular drive:

  • Either call the BIOS SELDSK routine. This returns the address of the DPH. The word at offset 10 in the DPH is the address of the DPB.
  • Or, the word at location #BE40 contains the address of the DPH vector. The first DPH is for drive A, the second for drive B.
  • Or use BDOS function 31.

When calling SELDSK if bit 0 of E = 0 and byte 24 of the XPB = #00 then the BIOS will attempt to determine the format of the disc and patch the XPB accordingly.

The XPBs for the different formats are initialized as follows:

System Format

  • 36 SPT, records per track
  • 3 BSH, block shift
  • 7 BLM, block mask
  • 0 EXM, extent mask
  • 170 DSM, number of blocks -1
  • 63 DRM, number of directory entries -1
  • #C0 AL0, 2 directory blocks
  • #00 AL1
  • 16 CKS, size of checksum vector
  • 2 OFF, reserved tracks
  • #41 first sector number
  • 9 sectors per track
  • 42 gap length (read/write)
  • 82 gap length (format)
  • #E9 filler byte
  • 2 log2(sectorsize)-7
  • 4 records per sector
  • 0 current track
  • 0 not aligned
  • 0 do auto select format

Data Only Format

  • 36 SPT, records per track
  • 3 BSH, block shift
  • 7 BLM, block mask
  • 0 EXM, extent mask
  • 179 DSM, number of blocks -1
  • 63 DRM, number of directory entries -1
  • #C0 ALO, 2 directory blocks #00 AL1
  • 16 CKS, size of checksum vector
  • 0 OFF, reserved tracks
  • # C1 first sector number
  • 9 sectors per track
  • 42 gap length (read/write)
  • 82 gap length (format)
  • #E9 filler byte
  • 2 log2(sector size) - 7
  • 4 records per sector
  • 0 current track
  • 0 not aligned
  • 0 do auto select format

IBM Format

  • 32 SPT, records per track
  • 3 BSH, block shift
  • 7 BLM, block mask
  • 0 EXM, extent mask
  • 155 DSM, number of blocks -1
  • 63 DRM, number of directory entries -1
  • #CO AL0, 2 directory blocks
  • #00 AL1
  • 16 CKS, size of checksum vector
  • 1 OFF, reserved tracks
  • #01 first sector number
  • 8 sectors per track
  • 42 gap length (read/write)
  • 80 gap length (format)
  • #E9 filler byte
  • 2 log2(sector size) - 7
  • 4 records per sector
  • 0 current track
  • 0 not aligned
  • 0 do auto select format

2.16 The Restart Instructions and Locations

The BIOS uses the restart instructions and their locations as follows:

  • RST0 : used by CP/M
  • RST1. .RST 5 : used for firmware calls etc.
  • RST 6 : available to the user - used by DDT.
  • RST 7 : used for interrupts.

An application program may use RST6 without any further ado.

An application program may not use RST7 or its location since this is used for interrupts - unless, that is, the program wishes to intercept interrupts.

If an application program wishes to use the restart instructions 1..5 and/or their locations for its own purposes then it must intercept all entries into the BIOS and restore the restart locations.

Initially copy the required restart location(s) into RAM. On entry to a BIOS routine, and again on exit, swap the restart location(s) with the RAM version.

If an application program does not call the BIOS directly then only the BDOS entry at #0005 need be intercepted.

The restart location(s) must also be restored if any firmware or extended BIOS jumpblock routines are called.

The DDT program supplied has been modified to use RST6 instead of the usual RST7.

2.17 Using the Alternate Register Set and the ENTER FIRMWARE Routine

The firmware uses BC' and carry' for its own purposes and corrupts the other alternate registers and IY. If an application program wishes to use these registers then the BIOS will automatically save the users alternate and IY registers on entry into the BIOS and restore them on exit. While inside the BIOS these registers are set as required by the firmware. If the application programs call firmware or extended BIOS routines then they must be called via the ENTER FIRMWARE routine which performs the necessary register saving.

The routine SET REG SAVE sets or clears the register saving option.

If register saving is enabled then an application program:

  • May use the alternate and IY registers.
  • May keep the stack under a ROM.
  • Must use the ENTER FIRMWARE routine for calling firmware and extended
  • BIOS routines.

    (It is not recommended, but exceptionally a firmware routine can be called directly if both the user and the routine called preserve BC' and carry' and the stack is not under a ROM. Routines which change the screen mode or the ROM enable state will change BC'.)

If register saving is disabled then an application program:

  • Must not use the alternate registers.
  • If the stack is under a ROM then must use the ENTER FIRMWARE routine.
  • If the stack is not under a ROM then may call the firmware directly.
  • The BIOS will corrupt IY.

It is strongly recommended that the BIOS is run with the alternate register saving enabled and that application programs follow the procedure outlined above. If an application program does disable the register saving it should re-enable it on exit. Otherwise certain standard application programs may not work.

SET REG SAVE must not be called via ENTER FIRMWARE.

See the firmware documentation for more details on the use of the alternate registers.

Note: the SETUP utility describes register saving enabled as ‘slow' and disabled as ‘fast'; these terms are misleading. The difference in speed is negligible.

★ AUTHOR: Paul OVERELL
★ NOTE: RÉF SOFT158A

Page précédente : DDI-1 Firmware: Chapter 2 - CP/M 2.2 and the BIOS (2/3)
Je participe au site:

» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop
Page créée en 053 millisecondes et consultée 358 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.