IDE HARD DISK PROGRAMMING REFERENCE FOR SIMPLE (8-bit) INTERFACE Port addresses: (Spectrum 128 compatible). Data register : #2B Parameter reg.: #2F Sector count r.: #6B Start sector r.: #6F Cylinder low : #AB Cylinder high : #AF Head reg. : #EB Command/status: #EF Example routines for read & write: ;I/O port addresses DAT EQU #2B PAR EQU #2F SEC EQU #6B STA EQU #6F ZYL EQU #AB ZYH EQU #AF HEA EQU #EB COM EQU #EF ;Enter parameters for Read & Write: HL address, BC start sector, ;A sector count, DE cylinder offset ;Out parameters: If zero flag set - OK , else error ;Sector length is 256 bytes in this case !!! (8-bit interface) REABE CALL REABL ;block read with error test. Entry point. ERRT ;error testing EI RET Z ;return to caller if no error IN A,(PAR) BIT 6,A JR NZ,ECCE RST 8 DEFB #1E ;Disk error - new error message code, this is an example & requires changes in ROM. ECCE RST 8 DEFB #1F ;ECC error... REABL CALL CALC LD A,#20 ;read command OUT (COM),A CWR CALL WAIDR SELL INI INI INI INI INI INI INI INI ;8 bytes in 1 pass DJNZ SELL IN A,(COM) BIT 0,A ;is error ? RET NZ DEC E ;decrease sector counter JR NZ,CWR RET ;with zero flag set - no error WRIBE CALL WRIBL ;Block write with error test. Entry point. JR ERRT WRIBL CALL CALC LD A,#30 ;write command OUT (COM),A WRIT CALL WAIDR SWRL OUTI OUTI OUTI OUTI OUTI OUTI OUTI OUTI DJNZ SWRL IN A,(COM) BIT 0,A RET NZ DEC E JR NZ,WRIT RET WAIDR LD BC,50000 ;time out counter prepare WAIDL IN A,(COM) BIT 3,A ; ready ? JR NZ,SET32 DEC BC LD A,B OR C JR NZ,WAIDL POP DE ;drop call. INC A ; reset zero flag RET ;time out SET32 LD BC,#2000+DAT ;set port address (C) & loop counter (B) : 8x#20=256 ; Here may be also LD B,#20 & LD C,DAT RET ;Below there will be some drive depending values HEADS EQU 7 ;this is an example - depends from used drive SECTOR EQU 17 ;also an example - sectors per track by used drive CALC OR A ;avoids zero sector count - it transfers 256 sectors! JR NZ,CONTIN RST 8 DEFB #19 ; parameter error CONTIN DI PUSH HL PUSH DE LD E,A LD H,B LD L,C LD D,-1 ; preset counter LD BC,-HEADS*SECTOR ; here comes the complement of HEAD ; and SECTOR product of the used drive CYLCL INC D ADD HL,BC JR C,CYLCL SBC HL,BC ;D now holds additional cyl. offset LD H,-1 LD A,L HEDCL INC H SUB SECTOR ; here comes sector(per track) param. of used drive JR NC,HEDCL ADD A,SECTOR+1 ;here comes sector(per track) plus 1... LD L,A LD A,H OR #A0 ;Master drive LD H,A ISEX IN A,(COM) BIT 7,A JR NZ,ISEX LD A,E OUT (SEC),A LD A,L OUT (STA),A LD A,H OUT (HEA),A POP HL LD C,D LD B,0 ADD HL,BC LD A,L OUT (ZYL),A LD A,H OUT (ZYH),A POP HL RET ;END With this routines transfer speed is about 100 KB per second by read and write. (From: Pera Putnik )