org 100h start: mvi a,00 mov c,a sta curdsk call setdrv mvi a,2 ; set track 2 call settrk call redtrk mvi a,01 ; select drive b call setdrv mvi a,2 call settrk call wrttrk jmp 0 trkreg equ 0e3fdh ; Morrow DJ2B track register settrk: mov c,a ; Enter with track # in acc sui 30h ; Force binary, if not already cpi 77 ; Test for legal range. maxtrk equ $-1 ; Set in proper max track #+1 jnc trkerr cpi 00h jc trkerr ; Negatives not allowed sta curtrk ; Make it current track call notbsy ; Make sure 1791 is idle sta trkreg ; and load track register adi 30h ; Make it ascii for possible sta asctrk ; use elsewhere. ret trkerr: call ccrlf call spmsg db ' Track number not acceptable.',0 xra a ; Set z flag ret curtrk db 1 ; CMDREG is part of SELCTDRV.LIB asctrk db 1 datreg equ 0fbffh ; Morrow DJ2B 1791 data port cmdreg equ 0fbfch ; Morrow DJ2B 1791 command port rtkcmd equ 000e4h ; 1791 read track command redtrk: call notbsy ; Wait until 1791 is idle lxi d,datreg ; Look at 1791 data register lxi h,trkbuf ; and set up buffer area mvi c,24 ; Load number of pages Šmaxpag equ $-1 ; to be read from track. mvi a,rtkcmd ; Load and issue track read sta cmdreg ; command for the 1791 datain: ldax d ; Load data byte mov m,a ; and store in buffer. inr l jnz datain ; Loop until all written. inr h dcr c jnz datain ret djcont equ 0e3f9h ; Morrow DJ2B drive control port djfunc equ 0e3fah ; Morrow DJ2B drive function port djdriv equ 0d31bh ; Morrow DJ2B BIOS setdrive entry djfunc equ 0e3fah ; Morrow DJ2B drive function port setdrv: mov a,c ; Save desired disk (in C on entry) ori 30h ; Make ascii if not already sta ascdsk ; and save it for possible use ani 07h ; Mask off to binary sta curdsk call djdriv ; Use the BIOS routine ret curdsk db 1 ascdsk db 1 wrtcmd equ 000f4h ; Write track command wrttrk: call notbsy ; Wait until 1791 idle lxi d,datreg ; Point to 1791 data port lxi h,trkbuf ; and to source code. mvi c,24 ; Set number of pages to be wrtpag equ $-1 ; written to disk mvi a,wrtcmd ; Get and issue a write sta cmdreg ; track command. xchg ; Swap the pointers- wrtlup: ldax d ; Get a data byte and dump mov m,a ; it into the 1791. Then inr e ; update the byte pointer to jnz wrtlup ; the next cell and continue inò ä »  untiì thå entirå buffeò haó dcr c ; been written to disk : one jnz wrtlup ; entire track's worth. ret Š spmsg: xthl readit: mov a,m ora a jz done inr l jnz readit inr h jmp readit done: xthl ret trkbuf ds 17ffh notbsy: mvi c,10 ; Preset counter wait1: lxi h,cmdreg ; Point to command port of mov a,m ; 1791 and get a status byte. rar ; Test busy flag - if not up, jnc timeot ; wait for it to come up for ; short period. wait2: mov a,m ; Get status byte and test for rar ; busy flag up. Loop until it jc wait2 ; comes down again. ret ; 1791 idle, go home. timeot: dcr c ; Don't look for flag to come up jnz wait1 ; forever. If no busy flag by ret ; ten tries, is not coming up. ccrlf: mvi a,0dh call co mvi a,0ah call co co: mvi c,2 call 5 ret