CP/M MACRO ASSEM 2.0	#001	mds cold start loader at 3000h

     1                  	TITLE   'mds cold start loader at 3000h'
     2                  ;
     3                  ;	MDS-800 COLD START LOADER FOR CP/M 2.0
     4                  ;
     5                  ;	VERSION 2.0 AUGUST, 1979
     6                  ;
     7   0000 =         FALSE	EQU	0
     8   FFFF =         TRUE	EQU	NOT FALSE
     9   0000 =         TESTING	EQU	FALSE    	;IF TRUE, THEN GO TO MON80 ON  ERRORS
    10                  ;
    11                  	IF	TESTING
    12                  BIAS	EQU	03400H
    13                  	ENDIF
    14                  	IF	NOT TESTING
    15   0000 =         BIAS	EQU	0000H
    16                  	ENDIF
    17   0000 =         CPMB	EQU	BIAS		;BASE OF DOS LOAD
    18   0806 =         BDOS	EQU	806H+BIAS	;ENTRY TO DOS FOR CALLS
    19   1880 =         BDOSE	EQU	1880H+BIAS	;END OF DOS LOAD
    20   1600 =         BOOT	EQU	1600H+BIAS	;COLD START ENTRY POINT
    21   1603 =         RBOOT	EQU	BOOT+3		;WARM START ENTRY POINT
    22                  ;
    23   3000           	ORG	03000H		;LOADED DOWN FROM HARDWARE BOOT AT 3000H
    24                  ;
    25   1880 =         BDOSL	EQU	BDOSE-CPMB
    26   0002 =         NTRKS	EQU	2		;NUMBER OF TRACKS TO READ
    27   0031 =         BDOSS	EQU	BDOSL/128	;NUMBER OF SECTORS IN DOS
    28   0019 =         BDOSO	EQU	25		;NUMBER OF BDOS SECTORS ON TRACK 0
    29   0018 =         BDOS1	EQU	BDOSS-BDOSO	;NUMBER OF SECTORS ON TRACK 1
    30                  ;
    31   F800 =         MON80	EQU	0F800H		;INTEL MONITOR BASE
    32   FF0F =         RMON80	EQU	0FF0FH		;RESTART LOCATION FOR MON80
    33   0078 =         BASE	EQU	078H		;'BASE' USED BY CONTROLLER
    34   0079 =         RTYPE	EQU	BASE+1		;RESULT TYPE
    35   007B =         RBYTE	EQU	BASE+3		;RESULT BYTE
    36   007F =         RESET	EQU	BASE+7		;RESET CONTROLLER
    37                  ;
    38                  ;
    39   0078 =         DSTAT	EQU	BASE		;DISK STATUS PORT
    40   0079 =         ILOW	EQU	BASE+1		;LOW IOPB ADDRESS
    41   007A =         IHIGH	EQU	BASE+2		;HIGH IOPB ADDRESS
    42   00FF =         BSW	EQU	0FFH		;BOOT SWITCH
    43   0003 =         RECAL	EQU	3H		;RECALIBRATE SELECTED DRIVE
    44   0004 =         READF	EQU	4H		;DISK READ FUNCTION
    45   0100 =         STACK	EQU	100H		;USE END OF BOOT FOR STACK
    46                  ;
    47                  RSTART:
    48   3000 310001    	LXI	SP,STACK;	;IN CASE OF CALL TO MON80
    49                  ;	CLEAR DISK STATUS
    50   3003 DB79      	IN	RTYPE
    51   3005 DB7B      	IN	RBYTE
    52                  ;	CHECK IF BOOT SWITCH IS OFF
    53                  COLDSTART:
    54   3007 DBFF      	IN 	BSW
    55   3009 E602      	ANI	02H		;SWITCH ON?
    56   300B C20730    	JNZ	COLDSTART
CP/M MACRO ASSEM 2.0	#002	mds cold start loader at 3000h

    57                  ;	CLEAR THE CONTROLLER
    58   300E D37F      	OUT	RESET		;LOGIC CLEARED
    59                  ;
    60                  ;
    61   3010 0602      	MVI	B,NTRKS		;NUMBER OF TRACKS TO READ
    62   3012 214230    	LXI	H,IOPBO
    63                  ;
    64                  START:
    65                  ;
    66                  ;	READ FIRST/NEXT TRACK INTO CPMB
    67   3015 7D        	MOV	A,L
    68   3016 D379      	OUT	ILOW
    69   3018 7C        	MOV	A,H
    70   3019 D37A      	OUT	IHIGH
    71   301B DB78      WAITO:	IN	DSTAT
    72   301D E604      	ANI	4
    73   301F CA1B30    	JZ	WAITO
    74                  ;
    75                  ;	CHECK	DISK STATUS
    76   3022 DB79      	IN	RTYPE
    77   3024 E603      	ANI	11B
    78   3026 FE02      	CPI	2
    79                  ;
    80                  	IF	TESTING
    81                  	CNC	RMON80		;GO TO MONITOR IF 11 OR 10
    82                  	ENDIF
    83                  	IF	NOT TESTING
    84   3028 D20030    	JNC	RSTART		;RETRY THE LOAD
    85                  	ENDIF
    86                  ;
    87   302B DB7B      	IN	RBYTE		;I/O COMPLETE, CHECK STATUS
    88                  ;	IF NOT	READY, THEN GO TO MON80
    89   302D 17        	RAL
    90   302E DC0FFF    	CC	RMON80		;NOT READY BIT SET
    91   3031 1F        	RAR			;RESTORE
    92   3032 E61E      	ANI	11110B		;OVERRUN/ADDR ERR/SEEK/CRC/XXXX
    93                  ;
    94                  	IF	TESTING
    95                  	CNZ	RMON80		;GO TO MONITOR
    96                  	ENDIF
    97                  	IF	NOT TESTING
    98   3034 C20030    	JNZ	RSTART		;RETRY THE LOAD
    99                  	ENDIF
   100                  ;
   101                  ;
   102   3037 110700    	LXI	D,IOPBL		;LENGTH OF IOPB
   103   303A 19        	DAD	D		;ADDRESSING NEXT IOPB
   104   303B 05        	DCR	B		;COUNT DOWN TRACKS
   105   303C C21530    	JNZ	START
   106                  ;
   107                  ;
   108                  ;	JMP TO BOOT TO PRINT INITIAL MESSAGE, AND SET UP JMPS
   109   303F C30016    	JMP	BOOT
   110                  ;
   111                  ;	PARAMETER BLOCKS
   112   3042 80        IOPBO:	DB	80H		;IOCW, NO UPDATE
CP/M MACRO ASSEM 2.0	#003	mds cold start loader at 3000h

   113   3043 04        	DB	READF		;READ FUNCTION
   114   3044 19        	DB	BDOSO		;*SECTORS TO READ ON TRACK 0
   115   3045 00        	DB	0		;TRACK 0
   116   3046 02        	DB	2		;START WITH SECTOR 2 ON TRACK 0
   117   3047 0000      	DW	CPMB		;START AT BASE OF BDOS
   118   0007 =         IOPBL	EQU	$-IOPBO
   119                  ;
   120   3049 80        IOPB1:	DB	80H
   121   304A 04        	DB	READF
   122   304B 18        	DB	BDOS1		;SECTORS TO READ ON TRACK 1
   123   304C 01        	DB	1		;TRACK 1
   124   304D 01        	DB	1		;SECTOR 1
   125   304E 800C      	DW	CPMB+BDOSO*128	;BASE OF SECOND READ
   126                  ;
   127   3050           	END
CP/M MACRO ASSEM 2.0	#004	mds cold start loader at 3000h

BASE             0078    33#   34    35    36    39    40    41 
BDOS             0806    18#
BDOS1            0018    29#  122 
BDOSE            1880    19#   25 
BDOSL            1880    25#   27 
BDOSO            0019    28#   29   114   125 
BDOSS            0031    27#   29 
BIAS             0000    12#   15#   17    18    19    20 
BOOT             1600    20#   21   109 
BSW              00FF    42#   54 
COLDSTART        3007    53#   56 
CPMB             0000    17#   25   117   125 
DSTAT            0078    39#   71 
FALSE            0000     7#    8     9 
IHIGH            007A    41#   70 
ILOW             0079    40#   68 
IOPB1            3049   120#
IOPBL            0007   102   118#
IOPBO            3042    62   112#  118 
MON80            F800    31#
NTRKS            0002    26#   61 
RBOOT            1603    21#
RBYTE            007B    35#   51    87 
READF            0004    44#  113   121 
RECAL            0003    43#
RESET            007F    36#   58 
RMON80           FF0F    32#   81    90    95 
RSTART           3000    47#   84    98 
RTYPE            0079    34#   50    76 
STACK            0100    45#   48 
START            3015    64#  105 
TESTING          0000     9#   11    14    80    83    94    97 
TRUE             FFFF     8#
WAITO            301B    71#   73 
