home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol236 / ldrbios.mac < prev    next >
Encoding:
Text File  |  1986-02-13  |  5.9 KB  |  212 lines

  1.     title    'LDRBIOS for CP/M 3.0'
  2.  
  3.         .z80
  4.  
  5. cr    equ 13
  6. lf    equ 10
  7. ntry    equ 4                   ; number of retries for disk read
  8.  
  9.         external adrv,dskdef    ; drive & disk tables
  10.  
  11. origin    equ     0E000H
  12. djboot    equ     origin          ;Disk Jockey 2D cold boot
  13. djcin    equ     origin+3h       ;Disk Jockey 2D character input routine
  14. djcout    equ    origin+6h    ;Disk Jockey 2D character output routine
  15. djhome    equ    origin+9h    ;Disk Jockey 2D track zero seek
  16. djtrk    equ    origin+0ch    ;Disk Jockey 2D track seek routine
  17. djsec    equ    origin+0fh    ;Disk Jockey 2D set sector routine
  18. djdma    equ    origin+12h    ;Disk Jockey 2D set DMA address
  19. djread    equ    origin+15h    ;Disk Jockey 2D read routine
  20. djwrit    equ    origin+18h    ;Disk Jockey 2D write routine
  21. djsel    equ    origin+1bh    ;Disk Jockey 2D select drive routine
  22. djtsta    equ    origin+21h    ;Disk Jockey 2D terminal status routine
  23. djstat    equ    origin+27h    ;Disk Jockey 2D status routine
  24. djerr    equ    origin+2ah    ;Disk Jockey 2D error, flash led
  25. djden    equ    origin+2dh    ;Disk Jockey 2D set density routine
  26. djside    equ    origin+30h    ;Disk Jockey 2D set side routine
  27. djleav  equ     origin+222h     ;leave routine in dj rom
  28. djprep  equ     origin+233h     ;prep routine in dj rom
  29.  
  30.     ; BIOS Jump vector.
  31.  
  32. ?boot:    jp boot         ; initial entry on cold start
  33. ?wboot:    jp wboot    ; reentry on program exit, warm start
  34.  
  35. ?const:    jp const    ; return console input status
  36. ?conin:    jp conin    ; return console input character
  37. ?cono:    jp conout    ; send console output character
  38. ?list:    jp list     ; send list output character
  39. ?auxo:    jp auxout    ; send auxilliary output character
  40. ?auxi:    jp auxin    ; return auxilliary input character
  41.  
  42. ?home:    jp home     ; set disks to logical home
  43. ?sldsk:    jp seldsk    ; select disk drive, return disk parameter info
  44. ?sttrk:    jp settrk    ; set disk track
  45. ?stsec:    jp setsec    ; set disk sector
  46. ?stdma:    jp setdma    ; set disk I/O memory address
  47. ?read:    jp read     ; read physical block(s)
  48. ?write:    jp write    ; write physical block(s)
  49.  
  50. ?lists:    jp listst    ; return list device status
  51. ?sctrn:    jp sectrn    ; translate logical to physical sector
  52.  
  53. ?conos:    jp conost    ; return console output status
  54. ?auxis:    jp auxist    ; return aux input status
  55. ?auxos:    jp auxost    ; return aux output status
  56. ?dvtbl:    jp devtbl    ; return address of device def table
  57. ?devin:    jp cinit    ; change baud rate of device
  58.  
  59. ?drtbl:    jp getdrv    ; return address of disk drive table
  60. ?mltio:    jp multio    ; set multiple record count for disk I/O
  61. ?flush:    jp flush    ; flush BIOS maintained disk caching
  62.  
  63. ?mov:    jp move     ; block move memory to memory
  64. ?tim:    jp time     ; Signal Time and Date operation
  65. ?bnksl:    jp bnksel    ; select bank for code execution and default DMA
  66. ?stbnk:    jp setbnk    ; select different bank for disk I/O DMA operations.
  67. ?xmov:    jp xmove    ; set source and destination banks for one operation
  68.  
  69.     jp fe        ; reserved for future expansion
  70.     jp fe        ; reserved for future expansion
  71.     jp fe        ; reserved for future expansion
  72.  
  73.  
  74. wboot:                  ; jump vector locations not used
  75. const:
  76. conin:
  77. list:
  78. auxout:
  79. auxin:
  80. write:
  81. listst:
  82. conost:
  83. auxist:
  84. auxost:
  85. devtbl:
  86. cinit:
  87. getdrv:
  88. multio:
  89. flush:
  90. time:
  91. bnksel:
  92. setbnk:
  93. xmove:
  94. fe:     ld hl,msg1               ; error halt
  95.         call ?pmsg
  96.         halt
  97. msg1:   db cr,lf,'CPMLDR failure: unimplemented bios call',cr,lf,0
  98.  
  99.  
  100. boot:
  101.         ld a,1                   ; reset output board
  102.         out (0e1h),a
  103.         ld a,0
  104.         out (0e1h),a
  105.  
  106. ; get disk type - assume reads of a non-zero track have already taken place
  107. ; so a dummy read is not necessary - adjust disk tables and set double
  108. ; sided indicator
  109.  
  110.         call djstat              ; get status word
  111.         ld (dsx),a               ; store for double sided indicator
  112.         rrca                     ; move right 
  113.         and 16h                  ; 2 * sec.lng.code + 16 * side.code
  114.         ld hl,dskdef             ; get table of disk table addresses
  115.         ld b,0
  116.         ld c,a
  117.         add hl,bc                ; hl points to address of skew table
  118.         ld de,adrv               ; de points to head of dph
  119.         ldi                      ; copy two bytes
  120.         ldi
  121.         ld bc,6
  122.         add hl,bc                ; address of pointer to dpb
  123.         ld bc,10
  124.         ex de,hl
  125.         add hl,bc                ; pointer to dpb in dph
  126.         ex de,hl
  127.         ldi                      ; copy two bytes
  128.         ldi
  129.  
  130.         ret
  131.  
  132. home:   call djhome
  133.         ret
  134.  
  135. seldsk: ld hl,adrv
  136.         ret
  137.  
  138. settrk: ld b,c
  139.         ld c,0
  140.         ld a,(dsx)               ; get status word
  141.         and 20h                  ; get bit 5
  142.         jr z,ss                  ; jump if single sided
  143.         srl b                    ; divide by 2
  144.         rl c                     ;    remainder to c
  145. ss:     call djside
  146.         ld c,b
  147.         call djtrk
  148.         jr c,lmsg3
  149.         ret
  150.  
  151. setsec: call djsec
  152.         jr c,lmsg3
  153.         ret
  154.         
  155. setdma: xor a
  156.         call djdma
  157.         and a
  158.         jr nz,lmsg3
  159.         ret
  160.  
  161. lmsg3:  ld hl,msg3
  162.         call ?pmsg
  163.         halt
  164. msg3:   db cr,lf,'CPMLDR failure: disk parameter error',cr,lf,0
  165.  
  166. read:   ld b,ntry                ; number of tries
  167. cycr:   push bc
  168.         call djread
  169.         pop bc
  170.         ld a,0
  171.         ret nc
  172.         djnz cycr
  173.         ld hl,msg4
  174.         call ?pmsg
  175.         halt
  176. msg4:   db cr,lf,'CPMLDR error: disk read error',cr,lf,0
  177.  
  178. sectrn: ex de,hl
  179.         add hl,bc
  180.         ld l,(hl)
  181.         ld h,0
  182.         ret
  183.  
  184. conout: in a,(0e1h)             ; get status
  185.         and 1
  186.         jr nz,conout            ; wait for buffer to clear
  187.         ld a,c
  188.         and 7fh                 ; blank parity
  189.         out (0e0h),a            ; output character
  190.         ret
  191.  
  192. move:
  193.     ex de,hl                ; we are passed source in DE and dest in HL
  194.     ldir                    ; use Z80 block move instruction
  195.     ex de,hl                ; need next addresses in same regs
  196.     ret
  197.  
  198. ?pmsg:                          ; print message @<HL> up to a null
  199.     ld a,(hl) 
  200.         or a 
  201.         ret z
  202.     ld c,a 
  203.         push hl
  204.     call ?cono 
  205.         pop hl
  206.     inc hl 
  207.         jr ?pmsg
  208.  
  209. dsx:    ds 1                    ; indicator for double sided disks
  210.  
  211.         end
  212.