Added CP/M tools

Added CP/M tools to build 86-DOS 0.11 under CP/M or Cromemco CDOS.
This commit is contained in:
Broken Pipe
2024-03-24 23:34:05 +00:00
parent a25b0e63b6
commit ff2d9aff6a
8 changed files with 3688 additions and 15 deletions
+4 -1
View File
@@ -1,8 +1,11 @@
# Auto detect text files and perform LF normalization
* text=auto
# 86-DOS text files must use CRLF and have 0x1A EOF markers, we simply mark them as binary
# 86-DOS and CP/M text files must use CRLF and have 0x1A EOF markers, we simply mark them as binary
*.a86 binary
*.asm binary
*.com binary
*.doc binary
*.hex binary
*.prn binary
*.z80 binary
+13 -13
View File
@@ -2237,8 +2237,8 @@ L1033:
MOV [L1B0E],AL
MOV BX,HEXBUF
MOV [HEXPNT],BX
MOV BX,L1C1B
MOV [L1B13],BX
MOV BX,LSTBUF
MOV [LSTPNT],BX
MOV BX,0
MOV [ERRCNT],BX
MOV [PC],BX
@@ -2447,13 +2447,13 @@ LIST:
XCHG AH,AL
AND AL,7FH
PUSH BX
MOV BX,[L1B13]
MOV BX,[LSTPNT]
MOV [BX],AL
CALL L1546
MOV [L1B13],BX
MOV [LSTPNT],BX
JNZ L11EC
MOV BX,L1C1B
MOV [L1B13],BX
MOV BX,LSTBUF
MOV [LSTPNT],BX
PUSH DX
XCHG DX,BX
PUSH CX
@@ -2591,8 +2591,8 @@ EXIT: JMP 0
RET
L12D6:
MOV AX,[L1B13]
CMP AX,L1C1B
MOV AX,[LSTPNT]
CMP AX,LSTBUF
JZ RET
MOV AL,1AH
CALL LIST
@@ -2951,9 +2951,9 @@ L1546:
INC BX
CMP BX,HEXBUF+128
JZ RET
CMP BX,L1C1B+128
JZ RET
CMP BX,LSTBUF+128
JZ RET
CMP BX,L1B9B+128
JNZ RET
MOV BX,HEXBUF
RET
@@ -3663,13 +3663,13 @@ L1B0F: DS 1
L1B10: DS 1
IFFLG: DS 1
CHKLAB: DS 1
L1B13: DS 2
LSTPNT: DS 2
ERRCNT: DS 2
LSTRET: DS 2
RETPT: DS 2
HEXBUF: DS 128
L1B9B: DS 128
LSTBUF: DS 128
L1C1B: DS 128
BC: DS 2
DE: DS 2
HL: DS 2
@@ -3678,4 +3678,4 @@ IY: DS 2
DS 50
STACK: EQU $
START: EQU $


Binary file not shown.
+3279
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
+312
View File
@@ -0,0 +1,312 @@
; DOSGEN The SYSGEN for 86-DOS version 1.00
; by Broken Pipe
; Runs on the Z80 under CP/M
SECSIZ: EQU 128 ;128 bytes per sector
SPT: EQU 26 ;26 sectors per track
SYSTRK: EQU 2 ;2 system tracks
;
; BIOS call offsets.
;
SELDSK: EQU 24
SETTRK: EQU 27
SETSEC: EQU 30
SETDMA: EQU 33
WRITE: EQU 39
;
; BDOS call numbers.
;
WRITESTR: EQU 9
DRVSET: EQU 14
OPEN: EQU 15
READ: EQU 20
DRVGET: EQU 25
DMAOFF: EQU 26
;
; Zero Page and FCB fields.
;
BDOS: EQU 5
FCB: EQU 5CH
FCB2: EQU 6CH
EX: EQU 12
S1: EQU 13
S2: EQU 14
RC: EQU 15
ORG 100H
LD SP,STACK ;Setup new stack
LD C,DRVGET
CALL BDOS ;Get current drive
LD (CURDRV),A ;Save it for EXIT
LD A,(FCB) ;Get dest drive letter
OR A ;Default drive?
JR NZ,DRVOK ;No, all good
LD DE,DRVBAD ;Cannot transfer system to default drive
JR EXIT
DRVOK: DEC A ;Convert to actual drive number
LD (DRIVE),A
LD IX,BRCFCB ;Load boot record FCB
CALL FOPEN ;Open it
LD HL,PBOOT ;Set DMA to boot record in memory
CALL FREAD ;Read it
LD A,(FCB2+1) ;Get first char of second param
OR 20H ;Convert to lower case
CP 't' ;Temp disk?
JR Z,TMPIO ;Yes, use TMPBIO.COM for BIOS
LD IX,BIOFCB ;Load BIOS FCB
JR OPENIO
TMPIO: LD IX,TIOFCB ;Load temp BIOS FCB
OPENIO: CALL FOPEN ;Open it
LD HL,PBIOS ;Set DMA to BIOS in memory
CALL FREAD ;Read it
LD IX,DOSFCB ;Load DOS FCB
CALL FOPEN ;Open it
LD HL,PDOS ;Set DMA to DOS in memory
CALL FREAD ;Read it
LD A,(FCB2+1) ;Get first char of second param
OR 20H ;Convert to lower case
CP 't' ;Temp disk?
JR NZ,SKIP ;No, skip writing TMPCMD.COM
LD IX,CMDFCB ;Load CMD FCB
CALL FOPEN ;Open it
LD HL,PCMD ;Set DMA to CMD in memory
CALL FREAD ;Read it
SKIP: CALL WRTSYS ;Write system in memory to disk
LD DE,DONE ;Fall through to EXIT
;
; Prints the string in DE and exits. Does not return.
;
EXIT:
LD C,WRITESTR
CALL BDOS ;Print message
LD A,(CURDRV)
LD C,A
PUSH BC ;Save drive number
CALL SEL ;Restore old drive
LD C,DRVSET
POP DE ;Restore drive number
CALL BDOS
JP 0
;
; Opens a file with its FCB in IX. IX preserved, all other
; registers destroyed. Does not return if the requested file
; cannot be opened.
;
FOPEN:
LD (IX+EX),0 ;Set EX to 0
LD (IX+S1),0 ;Set S1 to 0
LD (IX+S2),0 ;Set S2 to 0
LD (IX+RC),0 ;Set RC to 0
LD C,OPEN
PUSH IX
POP DE ;DE points to FCB
PUSH IX ;Save registers
CALL BDOS ;Open file
POP IX ;Restore registers
CP -1 ;Error?
RET NZ ;No, return
LD DE,OFAIL
LD C,WRITESTR
PUSH IX ;Save registers
CALL BDOS ;Print first part of open fail message
POP IX ;Restore registers
LD (IX+12),'$' ;Turn FCB file name into a string
INC IX ;Point to the file name
PUSH IX
POP DE ;DE points to file name
LD C,WRITESTR
CALL BDOS ;Print it
LD DE,OPENER
JR EXIT ;Exit with last part of the message.
;
; Reads all records of a file pointed to by its FCB in IX to
; the DMA in HL. IX preserved, all other registers destroyed.
; Does not return if reading fails.
;
FREAD:
PUSH HL
POP DE ;DE points to DMA
LD C,DMAOFF
PUSH IX ;Save registers
PUSH HL
CALL BDOS ;Set DMA before reading
POP HL ;Restore registers
POP IX
LDREC: LD C,READ
PUSH IX
POP DE
PUSH IX ;Save registers
PUSH HL
CALL BDOS ;Read a record
POP HL ;Restore registers
POP IX
CP 0 ;Success?
JR NZ,CHKEND ;No, check if EOF
LD DE,128
ADD HL,DE ;Increment DMA by 128 bytes
JR FREAD ;Read next record
CHKEND: CP 1 ;EOF?
RET Z ;Yes, done
LD DE,RFAIL
LD C,WRITESTR
PUSH IX ;Save registers
CALL BDOS ;Print first part of read fail message
POP IX ;Restore registers
LD (IX+12),'$' ;Turn FCB file name into a string
INC IX ;Point to the file name
PUSH IX
POP DE ;DE points to file name
LD C,WRITESTR
CALL BDOS ;Print it
LD DE,RDERR
JP EXIT ;Exit with last part of the message.
;
; BIOS drive select routine, drive in C. All registers destroyed.
;
SEL:
LD HL,(1)
LD DE,SELDSK
ADD HL,DE
JP (HL)
;
; BIOS set track routine, track in C. All registers destroyed.
;
TRK:
LD HL,(1)
LD DE,SETTRK
ADD HL,DE
JP (HL)
;
; BIOS set sector routine, sector in C. All registers destroyed.
;
SEC:
LD HL,(1)
LD DE,SETSEC
ADD HL,DE
JP (HL)
;
; BIOS set DMA routine, DMA in BC. All registers destroyed.
;
DMA:
LD HL,(1)
LD DE,SETDMA
ADD HL,DE
JP (HL)
;
; BIOS disk write routine. All registers destroyed.
;
DWRITE:
LD HL,(1)
LD DE,WRITE
ADD HL,DE
JP (HL)
;
; Writes the system in memory at LOADP to the first SYSTRK tracks of
; the disk in (DRIVE). All registers destroyed.
;
WRTSYS:
LD HL,DRIVE
LD C,(HL)
CALL SEL ;Select dest drive
LD HL,LOADP-SECSIZ ;Load point in RAM for system - SECSIZ
LD (DMADDR),HL ;Save it
LD A,-1 ;Start with track = -1
LD (TRACK),A
WRTTRK: LD HL,TRACK
INC (HL) ;Next track
LD A,SYSTRK ;Number of system tracks
CP (HL) ;All system tracks done?
RET Z ;Yes, system transfer complete
LD C,(HL)
CALL TRK ;Set track number
LD A,-1 ;Start with sector = -1
LD (SECTOR),A
WRTSEC: LD A,SPT ;Sectors per track
LD HL,SECTOR
INC (HL) ;Next sector
CP (HL) ;All sectors done?
JR Z,WRTTRK ;Yes, track write complete
LD C,(HL) ;Get sector number
INC C ;One-based indexing
CALL SEC ;Set sector number
LD HL,(DMADDR)
LD BC,SECSIZ
ADD HL,BC ;Increment DMA
LD (DMADDR),HL
LD B,H
LD C,L ;BC = HL for DMA call
CALL DMA ;Set DMA
XOR A
LD (RETRY),A ;Clear retry count
TRYSEC: LD A,(RETRY) ;Get retry count
CP 10 ;Too many (more than 10) retries?
JR C,TRYOK ;No, can perform write
LD DE,WRTER ;Load write error message
JP EXIT ;Print and quit
TRYOK: INC A
LD (RETRY),A ;Increment retry count
CALL DWRITE ;Raw disk write
OR A ;Success?
JR Z,WRTSEC ;Yes, next sector
JR TRYSEC ;Retry the write
;
; Messages.
;
DRVBAD: DB 'Bad drive specification',13,10,'$'
OFAIL: DB 'Failed to open "$'
OPENER: DB '"',13,10,'$'
RFAIL: DB 'Failed to read "$'
RDERR: DB '"',13,10,'$'
WRTER: DB 'Disk write error',13,10,'$'
DONE: DB 'System transfered',13,10,'$'
;
; FCBs of system files. Open these from bottom to top, one at a time.
;
CMDFCB: DB 0,'TMPCMD COM'
DOSFCB: DB 0,'86DOS COM'
TIOFCB: DB 0,'TMPBIO COM'
BIOFCB: DB 0,'DOSIO COM'
BRCFCB: DB 0,'BOOT COM'
DS 24
;
; Global variables.
;
CURDRV: DS 1
DRIVE: DS 1
TRACK: DS 1
SECTOR: DS 1
DMADDR: DS 2
RETRY: DS 1
;
; Stack of 128 bytes.
;
DS 128
STACK:
;
; Load point of the 86-DOS system and pointers to different system
; components.
;
LOADP:
PBOOT: EQU $ ;Relative offset of BOOT (0 * 128)
PBIOS: EQU $+128 ;Relative offset of BIOS (1 * 128)
PDOS: EQU $+1152 ;Relative offset of 86DOS (9 * 128)
PCMD: EQU $+4480 ;Relative offset of TMPCMD (35 * 128)

+79
View File
@@ -0,0 +1,79 @@
# CP/M Building Tools
This folder contains some of the Z80 tools required for building and deploying 86-DOS 0.11 under CP/M (or Cromemco CDOS, the operating system [@TimPaterson](https://github.com/TimPaterson) used). You will need these if you wish to create a working copy of 86-DOS 0.11 from pure source code.
> [!WARNING]
> These tools have only been tested under Cromemco CDOS 2.x. There is no guarantee that they will work under the official CP/M operating system or other CP/M-like operating systems. The source files are to be assembled using Cromemco's CDOS Z80 assembler, and you must have a Z80 CPU to run the binaries.
## ASM86
This is a reconstruction of the SCP Z80/8086 Cross Assembler [@TimPaterson](https://github.com/TimPaterson) used to develop 86-DOS. Original copies of this cross assembler are long gone, and the only thing we have now is [a manual](https://bitsavers.org/pdf/seattleComputer/Z80_8086_Cross_Assembler_Preliminary.pdf) for it. Given that the 86-DOS <code>ASM</code> assembler is essentially an 8086 translation of this assembler, I wrote a utility that does the exact opposite of <code>TRANS</code> (named CIS) to translate 86-DOS 0.11's assembler back to Z80. After making some minor tweaks to the output, I was able to make it work, so here it is.
> [!TIP]
> The Z80 source of the assembler is actually easier to read than the 8086 source because this assembler was originally written in the Z80 assembly language. When it was translated to 8086, a lot of boilerplate code were added, which made the code slightly difficult to follow. Now that it has been translated back to Z80, those boilerplate code have been removed.
ASM86 takes the following parameters: <code>[x:]ASM86 [y:]name[.ijk] [S]</code>
where
<table>
<colgroup>
<col style="width: 15%;">
<col style="width: 85%;">
</colgroup>
<tbody>
<tr>
<td>x</td>
<td>is an optional disk drive specifier indicating the location of the <code>ASM86.COM</code> file. This parameter is required only if the COM file is <u>NOT</u> located on either drive A or the current drive. Legal values are A, B, C, and D.</td>
</tr>
<tr>
<td>y</td>
<td>is an optional disk drive specifier indicating the location of the source file. This paramter may be omitted if the source file is on the current drive.</td>
</tr>
<tr>
<td>name</td>
<td>is the name of the 8086 assembly language source file, without the 3-letter extension. The extension <code>A86</code> is always assumed and may not be overriden.</td>
</tr>
<tr>
<td>ijk</td>
<td>is an optional 3-letter drive assigment parameter. The first letter is the name of the drive on which the source file will be found. This overrides a disk specifier which precedes the file name. The second letter is the name of the drive to which the hex object file will be written, or <code>Z</code> if no object file is desired. The third letter is the name of the drive to which the listing file will be written, or <code>X</code> to send the listing to the console, or <code>Z</code> if no listing file is desired. Assembling with no listing is much faster since the source file will not be read from disk a second time.</td>
</tr>
<tr>
<td><code>S</code></td>
<td>is an optional switch indicating that a symbol table is to be placed at the end of the listing.</td>
</tr>
</tbody>
</table>
This assembler can only produce Intel HEX files for object code, therefore you must convert them to binary before they can be executed on the 8086. Under CP/M, this can be done using the <code>LOAD</code> command. If you are using CDOS, which does not have <code>LOAD</code>, you will have to use <code>DEBUG</code> to load the .HEX file to memory and <code>SAVE</code> to save the loaded pages as a disk file.
> [!TIP]
> Don't forget to rename the source files from <code>.ASM</code> to <code>.A86</code>.
## DOSGEN
This is a tool I wrote to copy 86-DOS system files to the system area of IBM 8" SSSD floppies. It works in a similar way to CP/M's <code>SYSGEN</code> utility.
DOSGEN takes the following parameters: <code>[x:]DOSGEN y: [T]</code>
where
<table>
<colgroup>
<col style="width: 15%;">
<col style="width: 85%;">
</colgroup>
<tbody>
<tr>
<td>x</td>
<td>is an optional disk drive specifier indicating the location of the <code>DOSGEN.COM</code> file. This parameter is required only if the COM file is <u>NOT</u> located on either drive A or the current drive. Legal values are A, B, C, and D.</td>
</tr>
<tr>
<td>y</td>
<td>is a disk drive specifier indicating the disk upon which the 86-DOS system is to be written.</td>
</tr>
<tr>
<td><code>T</code></td>
<td>is an optional switch indicating that a temporary copy of the system is to be used. A temporary system includes a temporary BIOS and a temporary command interpreter. Normally, the BIOS uses DOS to load the command interpreter, <code>COMMAND.COM</code>, from the file area. The temporary BIOS loads the command interpreter directly from the system area. This is useful when 86-DOS is being built and deployed for the first time, as the command interpreter cannot be put into the file area without a working copy of DOS, and a working copy of DOS needs the command interpreter. The temporary command interpreter differs from the normal command interpreter in that it includes <code>RDCPM</code> as an internal command. This is needed for copying the actual command interpreter from CP/M disks to DOS disks once the temporary system is booted.</td>
</tr>
</tbody>
</table>
To copy 86-DOS to a new floppy disk, you must have the files <code>BOOT.COM</code>, <code>DOSIO.COM</code> and <code>86DOS.COM</code> on the current drive. If a temporary system is to be copied, <code>TMPBIO.COM</code> and <code>TMPCMD.COM</code> must also exist.
+1 -1
View File
@@ -32,7 +32,7 @@ This project acknowledges the intellectual property rights of Microsoft Corporat
By accessing and using the reconstructed source code provided in this repository, you agree to do so at your own risk and assume all responsibility for any legal implications that may arise.
## Building
All source files must be built using Seattle Computer Products' ASM-86 assembler. According to binary fragments found in the uninitialized data areas of executables, this version of 86-DOS was originally built under CP/M-80 2.2. However, since the CP/M-80 version of ASM-86 is not available online, the source files can only be assembled under DOS or Windows using the DOS version of ASM-86, branded simply as ASM. All assembly language source files in this repository use the extension <code>.ASM</code> so that they are accepted by the ASM assembler. Should a CP/M-80 version of ASM-86 surface one day, and if these files are to be built under CP/M, the extensions of the source files must be changed to <code>.A86</code>.
All source files must be built using Seattle Computer Products' ASM-86 assembler. According to binary fragments found in the uninitialized data areas of executables, this version of 86-DOS was originally built under CDOS 2.x (a CP/M-like operating system developed by Cromemco). All assembly language source files in this repository use the extension <code>.ASM</code>, so that they are accepted by the DOS version of the ASM-86 assembler, branded simply as ASM. Should this operating system be built under CDOS or CP/M, the extensions of the source files must be changed to <code>.A86</code>.
### Source to Object
To assemble a source file, invoke ASM with the command line: