Appendix A

The MDS Basic I/O System (BIOS)


NOTE

This appendix consists of a cross-reference listing generated by the XREF utility from the results of assembly with MAC. The original source file used to generate this listing is available here.


     1                  ;	MDS-800 I/O DRIVERS FOR CP/M 2.2
     2                  ;	(FOUR DRIVE SINGLE DENSITY VERSION)
     3                  ;
     4                  ;	VERSION 2.2 FEBRUARY, 1980
     5                  ;
     6   0016 =         VERS	EQU	22	;VERSION 2.2
     7                  ;
     8                  ;	COPYRIGHT (C) 1980
     9                  ;	DIGITAL RESEARCH
    10                  ;	BOX 579, PACIFIC GROVE
    11                  ;	CALIFORNIA, 93950
    12                  ;
    13                  ;
    14   FFFF =         TRUE	EQU	0FFFFH	;VALUE OF "TRUE"
    15   0000 =         FALSE	EQU	NOT TRUE	;"FALSE"
    16   0000 =         TEST	EQU	FALSE	;TRUE IF TEST BIOS
    17                  ;
    18                  	IF	TEST
    19                  BIAS	EQU	03400H	;BASE OF CCP IN TEST SYSTEM
    20                  	ENDIF
    21                  	IF	NOT TEST
    22   0000 =         BIAS	EQU	0000H	;GENERATE RELOCATABLE CP/M SYSTEM
    23                  	ENDIF
    24                  ;
    25   1600 =         PATCH	EQU	1600H
    26                  ;
    27   1600           	ORG	PATCH
    28   0000 =         CPMB	EQU	$-PATCH	;BASE OF CPM CONSOLE PROCESSOR
    29   0806 =         BDOS	EQU	806H+CPMB	;BASIC DOS (RESIDENT PORTION)
    30   1600 =         CPML	EQU	$-CPMB	;LENGTH (IN BYTES) OF CPM SYSTEM
    31   002C =         NSECTS	EQU	CPML/128	;NUMBER OF SECTORS TO LOAD
    32   0002 =         OFFSET	EQU	2	;NUMBER OF DISK TRACKS USED BY CP/M
    33   0004 =         CDISK	EQU	0004H	;ADDRESS OF LAST LOGGED DISK ON WARM START
    34   0080 =         BUFF	EQU	0080H	;DEFAULT BUFFER ADDRESS
    35   000A =         RETRY	EQU	10	;MAX RETRIES ON DISK I/O BEFORE ERROR
    36                  ;
    37                  ;	PERFORM FOLLOWING FUNCTIONS
    38                  ;	BOOT	COLD START
    39                  ;	WBOOT	WARM START (SAVE I/O BYTE)
    40                  ;	(BOOT AND WBOOT ARE THE SAME FOR MDS)
    41                  ;	CONST	CONSOLE STATUS
    42                  ;		REG-A = 00 IF NO CHARACTER READY
    43                  ;		REG-A = FF IF CHARACTER READY
    44                  ;	CONIN	CONSOLE CHARACTER IN (RESULT IN REG-A)
    45                  ;	CONOUT	CONSOLE CHARACTER OUT (CHAR IN REG-C)
    46                  ;	LIST	LIST OUT (CHAR IN REG-C)
    47                  ;	PUNCH	PUNCH OUT (CHAR IN REG-C)
    48                  ;	READER	PAPER TAPE READER IN (RESULT TO REG-A)
    49                  ;	HOME	MOVE TO TRACK 00
    50                  ;
    51                  ;	(THE FOLLOWING CALLS SET-UP THE IO PARAMETER BLOCK FOR THE
    52                  ;	MDS, WHICH IS USED TO PERFORM SUBSEQUENT READS AND WRITES)
    53                  ;	SELDSK	SELECT DISK GIVEN BY REG-C (0,1,2...)
    54                  ;	SETTRK	SET TRACK ADDRESS (0,...76) FOR SUBSEQUENT READ/WRITE
    55                  ;	SETSEC	SET SECTOR ADDRESS (1,...,26) FOR SUBSEQUENT READ/WRITE
    56                  ;	SETDMA	SET SUBSEQUENT DMA ADDRESS (INITIALLY 80H)
    57                  ;
    58                  ;	(READ AND WRITE ASSUME PREVIOUS CALLS TO SET UP THE IO PARAMETERS)
    59                  ;	READ	READ TRACK/SECTOR TO PRESET DMA ADDRESS
    60                  ;	WRITE	WRITE TRACK/SECTOR FROM PRESET DMA ADDRESS
    61                  ;
    62                  ;	JUMP VECTOR FOR INDIVIUAL ROUTINES
    63   1600 C3B316    	JMP	BOOT
    64   1603 C3C316    WBOOTE:	JMP	WBOOT
    65   1606 C36117    	JMP	CONST
    66   1609 C36417    	JMP	CONIN
    67   160C C36A17    	JMP	CONOUT
    68   160F C36D17    	JMP	LIST
    69   1612 C37217    	JMP	PUNCH
    70   1615 C37517    	JMP	READER
    71   1618 C37817    	JMP	HOME
    72   161B C37D17    	JMP	SELDSK
    73   161E C3A717    	JMP	SETTRK
    74   1621 C3AC17    	JMP	SETSEC
    75   1624 C3BB17    	JMP	SETDMA
    76   1627 C3C117    	JMP	READ
    77   162A C3CA17    	JMP	WRITE
    78   162D C37017    	JMP	LISTST	;LIST STATUS
    79   1630 C3B117    	JMP	SECTRAN
    80                  ;
    81                  	MACLIB	DISKDEF	;LOAD THE DISK DEFINITION LIBRARY
    82                  	DISKS	4	;FOUR DISKS
    83   1633+=         DPBASE	EQU	$	;BASE OF DISK PARAMETER BLOCKS
    84   1633+82160000  DPE0:	DW	XLT0,0000H	;TRANSLATE TABLE
    85   1637+00000000  	DW	0000H,0000H	;SCRATCH AREA
    86   163B+6E187316  	DW	DIRBUF,DPB0	;DIR BUFF,PARM BLOCK
    87   163F+0D19EE18  	DW	CSV0,ALV0	;CHECK, ALLOC VECTORS
    88   1643+82160000  DPE1:	DW	XLT1,0000H	;TRANSLATE TABLE
    89   1647+00000000  	DW	0000H,0000H	;SCRATCH AREA
    90   164B+6E187316  	DW	DIRBUF,DPB1	;DIR BUFF,PARM BLOCK
    91   164F+3C191D19  	DW	CSV1,ALV1	;CHECK, ALLOC VECTORS
    92   1653+82160000  DPE2:	DW	XLT2,0000H	;TRANSLATE TABLE
    93   1657+00000000  	DW	0000H,0000H	;SCRATCH AREA
    94   165B+6E187316  	DW	DIRBUF,DPB2	;DIR BUFF,PARM BLOCK
    95   165F+6B194C19  	DW	CSV2,ALV2	;CHECK, ALLOC VECTORS
    96   1663+82160000  DPE3:	DW	XLT3,0000H	;TRANSLATE TABLE
    97   1667+00000000  	DW	0000H,0000H	;SCRATCH AREA
    98   166B+6E187316  	DW	DIRBUF,DPB3	;DIR BUFF,PARM BLOCK
    99   166F+9A197B19  	DW	CSV3,ALV3	;CHECK, ALLOC VECTORS
   100                  	DISKDEF	0,1,26,6,1024,243,64,64,OFFSET
   101   1673+=         DPB0	EQU	$		;DISK PARM BLOCK
   102   1673+1A00      	DW	26		;SEC PER TRACK
   103   1675+03        	DB	3		;BLOCK SHIFT
   104   1676+07        	DB	7		;BLOCK MASK
   105   1677+00        	DB	0		;EXTNT MASK
   106   1678+F200      	DW	242		;DISK SIZE-1
   107   167A+3F00      	DW	63		;DIRECTORY MAX
   108   167C+C0        	DB	192		;ALLOC0
   109   167D+00        	DB	0		;ALLOC1
   110   167E+1000      	DW	16		;CHECK SIZE
   111   1680+0200      	DW	2		;OFFSET
   112   1682+=         XLT0	EQU	$		;TRANSLATE TABLE
   113   1682+01        	DB	1		
   114   1683+07        	DB	7		
   115   1684+0D        	DB	13		
   116   1685+13        	DB	19		
   117   1686+19        	DB	25		
   118   1687+05        	DB	5		
   119   1688+0B        	DB	11		
   120   1689+11        	DB	17		
   121   168A+17        	DB	23		
   122   168B+03        	DB	3		
   123   168C+09        	DB	9		
   124   168D+0F        	DB	15		
   125   168E+15        	DB	21		
   126   168F+02        	DB	2		
   127   1690+08        	DB	8		
   128   1691+0E        	DB	14		
   129   1692+14        	DB	20		
   130   1693+1A        	DB	26		
   131   1694+06        	DB	6		
   132   1695+0C        	DB	12		
   133   1696+12        	DB	18		
   134   1697+18        	DB	24		
   135   1698+04        	DB	4		
   136   1699+0A        	DB	10		
   137   169A+10        	DB	16		
   138   169B+16        	DB	22		
   139                  	DISKDEF	1,0
   140   1673+=         DPB1	EQU	DPB0	;EQUIVALENT PARAMETERS
   141   001F+=         ALS1	EQU	ALS0	;SAME ALLOCATION VECTOR SIZE
   142   0010+=         CSS1	EQU	CSS0	;SAME CHECKSUM VECTOR SIZE
   143   1682+=         XLT1	EQU	XLT0	;SAME TRANSLATE TABLE
   144                  	DISKDEF	2,0
   145   1673+=         DPB2	EQU	DPB0	;EQUIVALENT PARAMETERS
   146   001F+=         ALS2	EQU	ALS0	;SAME ALLOCATION VECTOR SIZE
   147   0010+=         CSS2	EQU	CSS0	;SAME CHECKSUM VECTOR SIZE
   148   1682+=         XLT2	EQU	XLT0	;SAME TRANSLATE TABLE
   149                  	DISKDEF	3,0
   150   1673+=         DPB3	EQU	DPB0	;EQUIVALENT PARAMETERS
   151   001F+=         ALS3	EQU	ALS0	;SAME ALLOCATION VECTOR SIZE
   152   0010+=         CSS3	EQU	CSS0	;SAME CHECKSUM VECTOR SIZE
   153   1682+=         XLT3	EQU	XLT0	;SAME TRANSLATE TABLE
   154                  ;	ENDEF OCCURS AT END OF ASSEMBLY
   155                  ;
   156                  ;	END OF CONTROLLER - INDEPENDENT CODE, THE REMAINING SUBROUTINES
   157                  ;	ARE TAILORED TO THE PARTICULAR OPERATING ENVIRONMENT, AND MUST
   158                  ;	BE ALTERED FOR ANY SYSTEM WHICH DIFFERS FROM THE INTEL MDS.
   159                  ;
   160                  ;	THE FOLLOWING CODE ASSUMES THE MDS MONITOR EXISTS AT 0F800H
   161                  ;	AND USES THE I/O SUBROUTINES WITHIN THE MONITOR
   162                  ;
   163                  ;	WE ALSO ASSUME THE MDS SYSTEM HAS FOUR DISK DRIVES
   164   00FD =         REVRT	EQU	0FDH	;INTERRUPT REVERT PORT
   165   00FC =         INTC	EQU	0FCH	;INTERRUPT MASK PORT
   166   00F3 =         ICON	EQU	0F3H	;INTERRUPT CONTROL PORT
   167   007E =         INTE	EQU	0111$1110B	;ENABLE RST 0(WARM BOOT), RST 7 (MONITOR)
   168                  ;
   169                  ;	MDS MONITOR EQUATES
   170   F800 =         MON80	EQU	0F800H	;MDS MONITOR
   171   FF0F =         RMON80	EQU	0FF0FH	;RESTART MON80 (BOOT ERROR)
   172   F803 =         CI	EQU	0F803H	;CONSOLE CHARACTER TO REG-A
   173   F806 =         RI	EQU	0F806H	;READER IN TO REG-A
   174   F809 =         CO	EQU	0F809H	;CONSOLE CHAR FROM C TO CONSOLE OUT
   175   F80C =         PO	EQU	0F80CH	;PUNCH CHAR FROM C TO PUNCH DEVICE
   176   F80F =         LO	EQU	0F80FH	;LIST FROM C TO LIST DEVICE
   177   F812 =         CSTS	EQU	0F812H	;CONSOLE STATUS 00/FF TO REGISTER A
   178                  ;
   179                  ;	DISK PORTS AND COMMANDS
   180   0078 =         BASE	EQU	78H	;BASE OF DISK COMMAND IO PORTS
   181   0078 =         DSTAT	EQU	BASE	;DISK STATUS (INPUT)
   182   0079 =         RTYPE	EQU	BASE+1	;RESULT TYPE (INPUT)
   183   007B =         RBYTE	EQU	BASE+3	;RESULT BYTE (INPUT)
   184                  ;
   185   0079 =         ILOW	EQU	BASE+1	;IOPB LOW ADDRESS (OUTPUT)
   186   007A =         IHIGH	EQU	BASE+2	;IOPB HIGH ADDRESS (OUTPUT)
   187                  ;
   188   0004 =         READF	EQU	4H	;READ FUNCTION
   189   0006 =         WRITF	EQU	6H	;WRITE FUNCTION
   190   0003 =         RECAL	EQU	3H	;RECALIBRATE DRIVE
   191   0004 =         IORDY	EQU	4H	;I/O FINISHED MASK
   192   000D =         CR	EQU	0DH	;CARRIAGE RETURN
   193   000A =         LF	EQU	0AH	;LINE FEED
   194                  ;
   195                  SIGNON:	;SIGNON MESSAGE: XXK CP/M VERS Y.Y
   196   169C 0D0A0A    	DB	CR,LF,LF
   197                  	IF	TEST
   198                  	DB	'32'	;32K EXAMPLE BIOS
   199                  	ENDIF
   200                  	IF	NOT TEST
   201   169F 3030      	DB	'00'	;MEMORY SIZE FILLED BY RELOCATOR
   202                  	ENDIF
   203   16A1 6B2043502F	DB	'k CP/M vers '
   204   16AD 322E32    	DB	VERS/10+'0','.',VERS MOD 10+'0'
   205   16B0 0D0A00    	DB	CR,LF,0
   206                  ;
   207                  BOOT:	;PRINT SIGNON MESSAGE AND GO TO CCP
   208                  ;	(NOTE: MDS BOOT INITIALIZED IOBYTE AT 0003H)
   209   16B3 310001    	LXI	SP,BUFF+80H
   210   16B6 219C16    	LXI	H,SIGNON
   211   16B9 CDD317    	CALL	PRMSG	;PRINT MESSAGE
   212   16BC AF        	XRA	A	;CLEAR ACCUMULATOR
   213   16BD 320400    	STA	CDISK	;SET INITIALLY TO DISK A
   214   16C0 C30F17    	JMP	GOCPM	;GO TO CP/M
   215                  ;
   216                  ;
   217                  WBOOT:;	LOADER ON TRACK 0, SECTOR 1, WHICH WILL BE SKIPPED FOR WARM 
   218                  ;	READ CP/M FROM DISK - ASSUMING THERE IS A 128 BYTE COLD START
   219                  ;	START.
   220                  ;
   221   16C3 318000    	LXI	SP,BUFF	;USING DMA - THUS 80 THRU FF AVAILABLE FOR STACK
   222                  ;
   223   16C6 0E0A      	MVI	C,RETRY	;MAX RETRIES
   224   16C8 C5        	PUSH	B
   225                  WBOOT0:	;ENTER HERE ON ERROR RETRIES
   226   16C9 010000    	LXI	B,CPMB	;SET DMA ADDRESS TO START OF DISK SYSTEM
   227   16CC CDBB17    	CALL	SETDMA
   228   16CF 0E00      	MVI	C,0	;BOOT FROM DRIVE 0
   229   16D1 CD7D17    	CALL	SELDSK
   230   16D4 0E00      	MVI	C,0
   231   16D6 CDA717    	CALL	SETTRK	;START WITH TRACK 0
   232   16D9 0E02      	MVI	C,2	;START READING SECTOR 2
   233   16DB CDAC17    	CALL	SETSEC
   234                  ;
   235                  ;	READ SECTORS, COUNT NSECTS TO ZERO
   236   16DE C1        	POP	B	;10-ERROR COUNT
   237   16DF 062C      	MVI	B,NSECTS
   238                  RDSEC:	;READ NEXT SECTOR
   239   16E1 C5        	PUSH	B	;SAVE SECTOR COUNT
   240   16E2 CDC117    	CALL	READ
   241   16E5 C24917    	JNZ	BOOTERR	;RETRY IF ERRORS OCCUR
   242   16E8 2A6C18    	LHLD	IOD	;INCREMENT DMA ADDRESS
   243   16EB 118000    	LXI	D,128	;SECTOR SIZE
   244   16EE 19        	DAD	D	;INCREMENTED DMA ADDRESS IN HL
   245   16EF 44        	MOV	B,H
   246   16F0 4D        	MOV	C,L	;READY FOR CALL TO SET DMA
   247   16F1 CDBB17    	CALL	SETDMA
   248   16F4 3A6B18    	LDA	IOS	;SECTOR NUMBER JUST READ
   249   16F7 FE1A      	CPI	26	;READ LAST SECTOR?
   250   16F9 DA0517    	JC	RD1
   251                  ;	MUST BE SECTOR 26, ZERO AND GO TO NEXT TRACK
   252   16FC 3A6A18    	LDA	IOT	;GET TRACK TO REGISTER A
   253   16FF 3C        	INR	A
   254   1700 4F        	MOV	C,A	;READY FOR CALL
   255   1701 CDA717    	CALL	SETTRK
   256   1704 AF        	XRA	A	;CLEAR SECTOR NUMBER
   257   1705 3C        RD1:	INR	A	;TO NEXT SECTOR
   258   1706 4F        	MOV	C,A	;READY FOR CALL
   259   1707 CDAC17    	CALL	SETSEC
   260   170A C1        	POP	B	;RECALL SECTOR COUNT
   261   170B 05        	DCR	B	;DONE?
   262   170C C2E116    	JNZ	RDSEC
   263                  ;
   264                  ;	DONE WITH THE LOAD, RESET DEFAULT BUFFER ADDRESS
   265                  GOCPM:	;(ENTER HERE FROM COLD START BOOT)
   266                  ;	ENABLE RST0 AND RST7
   267   170F F3        	DI
   268   1710 3E12      	MVI	A,12H	;INITIALIZE COMMAND
   269   1712 D3FD      	OUT	REVRT
   270   1714 AF        	XRA	A
   271   1715 D3FC      	OUT	INTC	;CLEARED
   272   1717 3E7E      	MVI	A,INTE	;RST0 AND RST7 BITS ON
   273   1719 D3FC      	OUT	INTC
   274   171B AF        	XRA	A
   275   171C D3F3      	OUT	ICON	;INTERRUPT CONTROL
   276                  ;
   277                  ;	SET DEFAULT BUFFER ADDRESS TO 80H
   278   171E 018000    	LXI	B,BUFF
   279   1721 CDBB17    	CALL	SETDMA
   280                  ;
   281                  ;	RESET MONITOR ENTRY POINTS
   282   1724 3EC3      	MVI	A,JMP
   283   1726 320000    	STA	0
   284   1729 210316    	LXI	H,WBOOTE
   285   172C 220100    	SHLD	1	;JMP WBOOT AT LOCATION 00
   286   172F 320500    	STA	5
   287   1732 210608    	LXI	H,BDOS
   288   1735 220600    	SHLD	6	;JMP BDOS AT LOCATION 5
   289                  	IF	NOT TEST
   290   1738 323800    	STA	7*8	;JMP TO MON80 (MAY HAVE BEEN CHANGED BY DDT)
   291   173B 2100F8    	LXI	H,MON80
   292   173E 223900    	SHLD	7*8+1
   293                  	ENDIF
   294                  ;	LEAVE IOBYTE SET
   295                  ;	PREVIOUSLY SELECTED DISK WAS B, SEND PARAMETER TO CPM
   296   1741 3A0400    	LDA	CDISK	;LAST LOGGED DISK NUMBER
   297   1744 4F        	MOV	C,A	;SEND TO CCP TO LOG IT IN
   298   1745 FB        	EI
   299   1746 C30000    	JMP	CPMB
   300                  ;
   301                  ;	ERROR CONDITION OCCURRED, PRINT MESSAGE AND RETRY
   302                  BOOTERR:
   303   1749 C1        	POP	B	;RECALL COUNTS
   304   174A 0D        	DCR	C
   305   174B CA5217    	JZ	BOOTER0
   306                  ;	TRY AGAIN
   307   174E C5        	PUSH	B
   308   174F C3C916    	JMP	WBOOT0
   309                  ;
   310                  BOOTER0:
   311                  ;	OTHERWISE TOO MANY RETRIES
   312   1752 215B17    	LXI	H,BOOTMSG
   313   1755 CDD317    	CALL	PRMSG
   314   1758 C30FFF    	JMP	RMON80	;MDS HARDWARE MONITOR
   315                  ;
   316                  BOOTMSG:
   317   175B 3F626F6F74	DB	'?boot',0
   318                  ;
   319                  ;
   320                  CONST:	;CONSOLE STATUS TO REG-A
   321                  ;	(EXACTLY THE SAME AS MDS CALL)
   322   1761 C312F8    	JMP	CSTS
   323                  ;
   324                  CONIN:	;CONSOLE CHARACTER TO REG-A
   325   1764 CD03F8    	CALL	CI
   326   1767 E67F      	ANI	7FH	;REMOVE PARITY BIT
   327   1769 C9        	RET
   328                  ;
   329                  CONOUT:	;CONSOLE CHARACTER FROM C TO CONSOLE OUT
   330   176A C309F8    	JMP	CO
   331                  ;
   332                  LIST:	;LIST DEVICE OUT
   333                  ;	(EXACTLY THE SAME AS MDS CALL)
   334   176D C30FF8    	JMP	LO
   335                  ;
   336                  LISTST:
   337                  	;RETURN LIST STATUS
   338   1770 AF        	XRA	A
   339   1771 C9        	RET		;ALWAYS NOT READY
   340                  ;
   341                  PUNCH:	;PUNCH DEVICE OUT
   342                  ;	(EXACTLY THE SAME AS MDS CALL)
   343   1772 C30CF8    	JMP	PO
   344                  ;
   345                  READER:	;READER CHARACTER IN TO REG-A
   346                  ;	(EXACTLY THE SAME AS MDS CALL)
   347   1775 C306F8    	JMP	RI
   348                  ;
   349                  HOME:	;MOVE TO HOME POSITION
   350                  ;	TREAT AS TRACK 00 SEEK
   351   1778 0E00      	MVI	C,0
   352   177A C3A717    	JMP	SETTRK
   353                  ;
   354                  SELDSK:	;SELECT DISK GIVEN BY REGISTER C
   355   177D 210000    	LXI	H,0000H	;RETURN 0000 IF ERROR
   356   1780 79        	MOV	A,C
   357   1781 FE04      	CPI	NDISKS	;TOO LARGE?
   358   1783 D0        	RNC		;LEAVE HL = 0000
   359                  ;
   360   1784 E602      	ANI	10B	;00 00 FOR DRIVE 0,1 AND 10 10 FOR DRIVE 2,3
   361   1786 326618    	STA	DBANK	;TO SELECT DRIVE BANK
   362   1789 79        	MOV	A,C	;00, 01, 10, 11
   363   178A E601      	ANI	1B	;MDS HAS 0,1 AT 78, 2,3 AT 88
   364   178C B7        	ORA	A	;RESULT 00?
   365   178D CA9217    	JZ	SETDRIVE
   366   1790 3E30      	MVI	A,00110000B	;SELECTS DRIVE 1 IN BANK
   367                  SETDRIVE:
   368   1792 47        	MOV	B,A	;SAVE THE FUNCTION
   369   1793 216818    	LXI	H,IOF	;IO FUNCTION
   370   1796 7E        	MOV	A,M
   371   1797 E6CF      	ANI	11001111B	;MASK OUT DISK NUMBER
   372   1799 B0        	ORA	B	;MASK IN NEW DISK NUMBER
   373   179A 77        	MOV	M,A	;SAVE IT IN IOPB
   374   179B 69        	MOV	L,C
   375   179C 2600      	MVI	H,0	;HL=DISK NUMBER
   376   179E 29        	DAD	H	;*2
   377   179F 29        	DAD	H	;*4
   378   17A0 29        	DAD	H	;*8
   379   17A1 29        	DAD	H	;*16
   380   17A2 113316    	LXI	D,DPBASE
   381   17A5 19        	DAD	D	;HL=DISK HEADER TABLE ADDRESS
   382   17A6 C9        	RET
   383                  ;
   384                  ;
   385                  SETTRK:	;SET TRACK ADDRESS GIVEN BY C
   386   17A7 216A18    	LXI	H,IOT
   387   17AA 71        	MOV	M,C
   388   17AB C9        	RET
   389                  ;
   390                  SETSEC:	;SET SECTOR NUMBER GIVEN BY C
   391   17AC 216B18    	LXI	H,IOS
   392   17AF 71        	MOV	M,C
   393   17B0 C9        	RET
   394                  SECTRAN:
   395                  		;TRANSLATE SECTOR BC USING TABLE AT DE
   396   17B1 0600      	MVI	B,0	;DOUBLE PRECISION SECTOR NUMBER IN BC
   397   17B3 EB        	XCHG		;TRANSLATE TABLE ADDRESS TO HL
   398   17B4 09        	DAD	B	;TRANSLATE(SECTOR) ADDRESS
   399   17B5 7E        	MOV	A,M	;TRANSLATED SECTOR NUMBER TO A
   400   17B6 326B18    	STA	IOS
   401   17B9 6F        	MOV	L,A	;RETURN SECTOR NUMBER IN L
   402   17BA C9        	RET
   403                  ;
   404                  SETDMA:	;SET DMA ADDRESS GIVEN BY REGS B,C
   405   17BB 69        	MOV	L,C
   406   17BC 60        	MOV	H,B
   407   17BD 226C18    	SHLD	IOD
   408   17C0 C9        	RET
   409                  ;
   410                  READ:	;READ NEXT DISK RECORD (ASSUMING DISK/TRK/SEC/DMA SET)
   411   17C1 0E04      	MVI	C,READF	;SET TO READ FUNCTION
   412   17C3 CDE017    	CALL	SETFUNC
   413   17C6 CDF017    	CALL	WAITIO	;PERFORM READ FUNCTION
   414   17C9 C9        	RET		;MAY HAVE ERROR SET IN REG-A
   415                  ;
   416                  ;
   417                  WRITE:	;DISK WRITE FUNCTION
   418   17CA 0E06      	MVI	C,WRITF
   419   17CC CDE017    	CALL	SETFUNC	;SET TO WRITE FUNCTION
   420   17CF CDF017    	CALL	WAITIO
   421   17D2 C9        	RET		;MAY HAVE ERROR SET
   422                  ;
   423                  ;
   424                  ;	UTILITY SUBROUTINES
   425                  PRMSG:	;PRINT MESSAGE AT H,L TO 0
   426   17D3 7E        	MOV	A,M
   427   17D4 B7        	ORA	A	;ZERO?
   428   17D5 C8        	RZ
   429                  ;	MORE TO PRINT
   430   17D6 E5        	PUSH	H
   431   17D7 4F        	MOV	C,A
   432   17D8 CD6A17    	CALL	CONOUT
   433   17DB E1        	POP	H
   434   17DC 23        	INX	H
   435   17DD C3D317    	JMP	PRMSG
   436                  ;
   437                  SETFUNC:
   438                  ;	SET FUNCTION FOR NEXT I/O (COMMAND IN REG-C)
   439   17E0 216818    	LXI	H,IOF	;IO FUNCTION ADDRESS
   440   17E3 7E        	MOV	A,M	;GET IT TO ACCUMULATOR FOR MASKING
   441   17E4 E6F8      	ANI	11111000B	;REMOVE PREVIOUS COMMAND
   442   17E6 B1        	ORA	C	;SET TO NEW COMMAND
   443   17E7 77        	MOV	M,A	;REPLACED IN IOPB
   444                  ;	THE MDS-800 CONTROLLER REQUIRES DISK BANK BIT IN SECTOR BYTE
   445                  ;	MASK THE BIT FROM THE CURRENT I/O FUNCTION
   446   17E8 E620      	ANI	00100000B	;MASK THE DISK SELECT BIT
   447   17EA 216B18    	LXI	H,IOS		;ADDRESS THE SECTOR SELECT BYTE
   448   17ED B6        	ORA	M		;SELECT PROPER DISK BANK
   449   17EE 77        	MOV	M,A		;SET DISK SELECT BIT ON/OFF
   450   17EF C9        	RET
   451                  ;
   452                  WAITIO:
   453   17F0 0E0A      	MVI	C,RETRY	;MAX RETRIES BEFORE PERM ERROR
   454                  REWAIT:
   455                  ;	START THE I/O FUNCTION AND WAIT FOR COMPLETION
   456   17F2 CD3F18    	CALL	INTYPE	;IN RTYPE
   457   17F5 CD4C18    	CALL	INBYTE	;CLEARS THE CONTROLLER
   458                  ;
   459   17F8 3A6618    	LDA	DBANK		;SET BANK FLAGS
   460   17FB B7        	ORA	A		;ZERO IF DRIVE 0,1 AND NZ IF 2,3
   461   17FC 3E67      	MVI	A,IOPB AND 0FFH	;LOW ADDRESS FOR IOPB
   462   17FE 0618      	MVI	B,IOPB SHR 8	;HIGH ADDRESS FOR IOPB
   463   1800 C20B18    	JNZ	IODR1	;DRIVE BANK 1?
   464   1803 D379      	OUT	ILOW		;LOW ADDRESS TO CONTROLLER
   465   1805 78        	MOV	A,B
   466   1806 D37A      	OUT	IHIGH	;HIGH ADDRESS
   467   1808 C31018    	JMP	WAIT0		;TO WAIT FOR COMPLETE
   468                  ;
   469                  IODR1:	;DRIVE BANK 1
   470   180B D389      	OUT	ILOW+10H	;88 FOR DRIVE BANK 10
   471   180D 78        	MOV	A,B
   472   180E D38A      	OUT	IHIGH+10H
   473                  ;
   474   1810 CD5918    WAIT0:	CALL	INSTAT		;WAIT FOR COMPLETION
   475   1813 E604      	ANI	IORDY		;READY?
   476   1815 CA1018    	JZ	WAIT0
   477                  ;
   478                  ;	CHECK IO COMPLETION OK
   479   1818 CD3F18    	CALL	INTYPE		;MUST BE IO COMPLETE (00) UNLINKED
   480                  ;	00 UNLINKED I/O COMPLETE,    01 LINKED I/O COMPLETE (NOT USED)
   481                  ;	10 DISK STATUS CHANGED       11 (NOT USED)
   482   181B FE02      	CPI	10B		;READY STATUS CHANGE?
   483   181D CA3218    	JZ	WREADY
   484                  ;
   485                  ;	MUST BE 00 IN THE ACCUMULATOR
   486   1820 B7        	ORA	A
   487   1821 C23818    	JNZ	WERROR		;SOME OTHER CONDITION, RETRY
   488                  ;
   489                  ;	CHECK I/O ERROR BITS
   490   1824 CD4C18    	CALL	INBYTE
   491   1827 17        	RAL
   492   1828 DA3218    	JC	WREADY		;UNIT NOT READY
   493   182B 1F        	RAR
   494   182C E6FE      	ANI	11111110B	;ANY OTHER ERRORS?  (DELETED DATA OK)
   495   182E C23818    	JNZ	WERROR
   496                  ;
   497                  ;	READ OR WRITE IS OK, ACCUMULATOR CONTAINS ZERO
   498   1831 C9        	RET
   499                  ;
   500                  WREADY:	;NOT READY, TREAT AS ERROR FOR NOW
   501   1832 CD4C18    	CALL	INBYTE		;CLEAR RESULT BYTE
   502   1835 C33818    	JMP	TRYCOUNT
   503                  ;
   504                  WERROR:	;RETURN HARDWARE MALFUNCTION (CRC, TRACK, SEEK, ETC.)
   505                  ;	THE MDS CONTROLLER HAS RETURNED A BIT IN EACH POSITION
   506                  ;	OF THE ACCUMULATOR, CORRESPONDING TO THE CONDITIONS:
   507                  ;	0	- DELETED DATA (ACCEPTED AS OK ABOVE)
   508                  ;	1	- CRC ERROR
   509                  ;	2	- SEEK ERROR
   510                  ;	3	- ADDRESS ERROR (HARDWARE MALFUNCTION)
   511                  ;	4	- DATA OVER/UNDER FLOW (HARDWARE MALFUNCTION)
   512                  ;	5	- WRITE PROTECT (TREATED AS NOT READY)
   513                  ;	6	- WRITE ERROR (HARDWARE MALFUNCTION)
   514                  ;	7	- NOT READY
   515                  ;	(ACCUMULATOR BITS ARE NUMBERED 7 6 5 4 3 2 1 0)
   516                  ;
   517                  ;	IT MAY BE USEFUL TO FILTER OUT THE VARIOUS CONDITIONS,
   518                  ;	BUT WE WILL GET A PERMANENT ERROR MESSAGE IF IT IS NOT
   519                  ;	RECOVERABLE.  IN ANY CASE, THE NOT READY CONDITION IS
   520                  ;	TREATED AS A SEPARATE CONDITION FOR LATER IMPROVEMENT
   521                  TRYCOUNT:
   522                  ;	REGISTER C CONTAINS RETRY COUNT, DECREMENT 'TIL ZERO
   523   1838 0D        	DCR	C
   524   1839 C2F217    	JNZ	REWAIT	;FOR ANOTHER TRY
   525                  ;
   526                  ;	CANNOT RECOVER FROM ERROR
   527   183C 3E01      	MVI	A,1	;ERROR CODE
   528   183E C9        	RET
   529                  ;
   530                  ;	INTYPE, INBYTE, INSTAT READ DRIVE BANK 00 OR 10
   531   183F 3A6618    INTYPE:	LDA	DBANK
   532   1842 B7        	ORA	A
   533   1843 C24918    	JNZ	INTYP1	;SKIP TO BANK 10
   534   1846 DB79      	IN	RTYPE
   535   1848 C9        	RET
   536   1849 DB89      INTYP1:	IN	RTYPE+10H	;78 FOR 0,1  88 FOR 2,3
   537   184B C9        	RET
   538                  ;
   539   184C 3A6618    INBYTE:	LDA	DBANK
   540   184F B7        	ORA	A
   541   1850 C25618    	JNZ	INBYT1
   542   1853 DB7B      	IN	RBYTE
   543   1855 C9        	RET
   544   1856 DB8B      INBYT1:	IN	RBYTE+10H
   545   1858 C9        	RET
   546                  ;
   547   1859 3A6618    INSTAT:	LDA	DBANK
   548   185C B7        	ORA	A
   549   185D C26318    	JNZ	INSTA1
   550   1860 DB78      	IN	DSTAT
   551   1862 C9        	RET
   552   1863 DB88      INSTA1:	IN	DSTAT+10H
   553   1865 C9        	RET
   554                  ;
   555                  ;
   556                  ;
   557                  ;	DATA AREAS (MUST BE IN RAM)
   558   1866 00        DBANK:	DB	0	;DISK BANK 00 IF DRIVE 0,1
   559                  			;	   10 IF DRIVE 2,3
   560                  IOPB:	;IO PARAMETER BLOCK
   561   1867 80        	DB	80H	;NORMAL I/O OPERATION
   562   1868 04        IOF:	DB	READF	;IO FUNCTION, INITIAL READ
   563   1869 01        ION:	DB	1	;NUMBER OF SECTORS TO READ
   564   186A 02        IOT:	DB	OFFSET	;TRACK NUMBER
   565   186B 01        IOS:	DB	1	;SECTOR NUMBER
   566   186C 8000      IOD:	DW	BUFF	;IO ADDRESS
   567                  ;
   568                  ;
   569                  ;	DEFINE RAM AREAS FOR BDOS OPERATION
   570                  	ENDEF
   571   186E+=         BEGDAT	EQU	$
   572   186E+          DIRBUF:	DS	128	;DIRECTORY ACCESS BUFFER
   573   18EE+          ALV0:	DS	31
   574   190D+          CSV0:	DS	16
   575   191D+          ALV1:	DS	31
   576   193C+          CSV1:	DS	16
   577   194C+          ALV2:	DS	31
   578   196B+          CSV2:	DS	16
   579   197B+          ALV3:	DS	31
   580   199A+          CSV3:	DS	16
   581   19AA+=         ENDDAT	EQU	$
   582   013C+=         DATSIZ	EQU	$-BEGDAT
   583   19AA           	END
ALS1             001F   141#
ALS2             001F   146#
ALS3             001F   151#
ALV0             18EE    87   573#
ALV1             191D    91   575#
ALV2             194C    95   577#
ALV3             197B    99   579#
BASE             0078   180#  181   182   183   185   186 
BDOS             0806    29#  287 
BEGDAT           186E   571#  582 
BIAS             0000    19#   22#
BOOT             16B3    63   207#
BOOTER0          1752   305   310#
BOOTERR          1749   241   302#
BOOTMSG          175B   312   316#
BUFF             0080    34#  209   221   278   566 
CDISK            0004    33#  213   296 
CI               F803   172#  325 
CO               F809   174#  330 
CONIN            1764    66   324#
CONOUT           176A    67   329#  432 
CONST            1761    65   320#
CPMB             0000    28#   29    30   226   299 
CPML             1600    30#   31 
CR               000D   192#  196   205 
CSS1             0010   142#
CSS2             0010   147#
CSS3             0010   152#
CSTS             F812   177#  322 
CSV0             190D    87   574#
CSV1             193C    91   576#
CSV2             196B    95   578#
CSV3             199A    99   580#
DATSIZ           013C   582#
DBANK            1866   361   459   531   539   547   558#
DIRBUF           186E    86    90    94    98   572#
DPB0             1673    86   101#  140   145   150 
DPB1             1673    90   140#
DPB2             1673    94   145#
DPB3             1673    98   150#
DPBASE           1633    83#  380 
DPE0             1633    84#
DPE1             1643    88#
DPE2             1653    92#
DPE3             1663    96#
DSTAT            0078   181#  550   552 
ENDDAT           19AA   581#
FALSE            0000    15#   16 
GOCPM            170F   214   265#
HOME             1778    71   349#
ICON             00F3   166#  275 
IHIGH            007A   186#  466   472 
ILOW             0079   185#  464   470 
INBYT1           1856   541   544#
INBYTE           184C   457   490   501   539#
INSTA1           1863   549   552#
INSTAT           1859   474   547#
INTC             00FC   165#  271   273 
INTE             007E   167#  272 
INTYP1           1849   533   536#
INTYPE           183F   456   479   531#
IOD              186C   242   407   566#
IODR1            180B   463   469#
IOF              1868   369   439   562#
ION              1869   563#
IOPB             1867   461   462   560#
IORDY            0004   191#  475 
IOS              186B   248   391   400   447   565#
IOT              186A   252   386   564#
LF               000A   193#  196   196   205 
LIST             176D    68   332#
LISTST           1770    78   336#
LO               F80F   176#  334 
MON80            F800   170#  291 
NSECTS           002C    31#  237 
OFFSET           0002    32#  100   564 
PATCH            1600    25#   27    28 
PO               F80C   175#  343 
PRMSG            17D3   211   313   425#  435 
PUNCH            1772    69   341#
RBYTE            007B   183#  542   544 
RD1              1705   250   257#
RDSEC            16E1   238#  262 
READ             17C1    76   240   410#
READER           1775    70   345#
READF            0004   188#  411   562 
RECAL            0003   190#
RETRY            000A    35#  223   453 
REVRT            00FD   164#  269 
REWAIT           17F2   454#  524 
RI               F806   173#  347 
RMON80           FF0F   171#  314 
RTYPE            0079   182#  534   536 
SECTRAN          17B1    79   394#
SELDSK           177D    72   229   354#
SETDMA           17BB    75   227   247   279   404#
SETDRIVE         1792   365   367#
SETFUNC          17E0   412   419   437#
SETSEC           17AC    74   233   259   390#
SETTRK           17A7    73   231   255   352   385#
SIGNON           169C   195#  210 
TEST             0000    16#   18    21   197   200   289 
TRUE             FFFF    14#   15 
TRYCOUNT         1838   502   521#
VERS             0016     6#  204   204 
WAIT0            1810   467   474#  476 
WAITIO           17F0   413   420   452#
WBOOT            16C3    64   217#
WBOOT0           16C9   225#  308 
WBOOTE           1603    64#  284 
WERROR           1838   487   495   504#
WREADY           1832   483   492   500#
WRITE            17CA    77   417#
WRITF            0006   189#  418 
XLT0             1682    84   112#  143   148   153 
XLT1             1682    88   143#
XLT2             1682    92   148#
XLT3             1682    96   153#


Back to title page       Next