Title Format Test Bed Program for the DJDMA (26_Apr_83) ;====================================================== ; ;Format a disk ; -load program ; -setup parameters ; -format first track ; -format remaining tracks ;Support Routines ; -Execute a controller command .z80 ;Written in Z80 Code cseg ;Make this a relative code section ;Equates ;------- ; ;Address/Port Definitions intcmd equ 50h ;Initial Channel Command Address vector equ 51h ;Vector Part of initial channel command address extdpg equ 53h ;Extended page Part of initial channel command address djport equ 0EFh ;I/O Port for the DJDMA loadad equ 1030h ;Load Address in the DJDMA ;DJDMA Op-Codes halt equ 25h ;Halt Execution branch equ 26h ;Branch in Channel load equ 0A1h ;Load the Controller's memory exec equ 0A2h ;Execute a command in Controller' memory ;DJDMA Execution Vectors trans equ 1040h ;Transfer the parameters into the code section first equ 1043h ;Format the initial track next equ 1046h ;Format subsequent tracks fmtnxt equ 1049h ;Format Next Surface (Current Surface Plus One) fmtlst equ 104Ch ;Format Last Surface (Current Surface Minus One) ;Other Equates MAXTRK equ strcod+1 ;Maximum Number of tracks MAXSID equ strcod+12 ;Maximum Number of sides (0=single, 1=double) PAGE 64 ;---------------------------------------------------------------------- ;Main Line of Code ;----------------- ; ld a,branch ld (intcmd),a ;Starting_Channel_Command:= Branch ld a,0 ld (extdpg),a ;Extended_page_address:= 0 ld (trkcnt),a ;Track_Counter:= 0 ld hl,ldnss call djexec ;Load the Format Program ld hl,transp call djexec ;Transfer the parameter block into the code ld hl,fmt0 call djexec ;Format the first track ld a,(MAXSID) ;If (Media is Double_Sided) or a jr z,fmtlp ld hl,fmtn call djexec ; Format the other side fmtlp: ld a,(trkcnt) ;While (Track_Count lt MAX-Track_Count) inc a ; (Track_Count:= Track_Count + 1) ld (trkcnt),a ld b,a ld a,(MAXTRK) cp b ret z ; (-> Zero = done all tracks) ld hl,fmtn call djexec ; Format the next track ld a,(MAXSID) ; If (Media is Double_Sided) or a jr z,fmtskp ld hl,fmtn call djexec ; Format the other Side fmtskp: jr fmtlp PAGE ;---------------------------------------------------------------------- ;Support Routines ;---------------- ; ;Execute a DJDMA Command String ;------------------------------ ; djexec: ld a,0 ld (comsts),a ;Reset the execution vector ld (vector),hl ;Set the execution vector out (djport),a ;Start the DJDMA djelp: ld a,(comsts) ;While (Status ne Done) or a jr z,djelp ret PAGE ;---------------------------------------------------------------------- ; Data Storage/DJDMA Command Strings ;----------------------------------- ; trkcnt: db 0 ;Track Count ;Load the Format Program ldnss: db load ;Load the Controller's memory dw strcod ; Location of format code in main memory db 0 ; (extended page) dw 0240h ; Format code length (Plus a little) dw loadad ; Load address in the DJDMA db branch ;Branch to Common Halt dw stop db 0 ;Transfer the parameter block into the code section transp: db exec ;Execute a command in Controller' memory dw trans db 0 db branch ;Branch to Common Halt dw stop db 0 ;Format the first track fmt0: db exec ;Execute a command in Controller' memory dw first db 0 db branch ;Branch to Common Halt dw stop db 0 ;Format the track again fmt_: db exec ;Execute a command in Controller' memory dw next db 0 db branch ;Branch to Common Halt dw stop db 0 ;Format the Next Track fmtn: db exec ;Execute a command in Controller' memory dw fmtnxt db 0 db branch ;Branch to Common Halt dw stop db 0 ;Format the Last Track fmtl: db exec ;Execute a command in Controller' memory dw fmtlst db 0 db branch ;Branch to Common Halt dw stop db 0 stop: db halt ;Halt Execution comsts: db 0 ;Common Status strcod: ;Label to identify the start of the dj-code end