home *** CD-ROM | disk | FTP | other *** search
/ The Don Maslin Archive / maslin_archive.zip / AARDVARK_Tape_Backups / maslin_c_d_3oct95 / ddrive / cpm / ldrbios.asm < prev    next >
Assembly Source File  |  1980-01-29  |  13KB  |  506 lines

  1. ;--------------------------------------------------------
  2. ;
  3. ;    PROGRAM ID:    GBIOS3.ASM
  4. ;            GENERIC LOADER AND BIOS FOR CP/M PLUS
  5. ;            FOR CP/M-80 V2.2 SYSTEMS
  6. ;            UNBANKED
  7. ;            NO HASHING
  8. ;            BIOS PERFORMS BLOCKING/DEBLOCKING
  9. ;
  10. ;--------------------------------------------------------
  11. ;
  12. ;    ORGANIZATIONAL COMMENTARY
  13. ;
  14. ;--------------------------------------------------------
  15. ;    This BIOS is designed to be the user's first step
  16. ;in making an upgrade from CP/M-80 v2.2 to CP/M Plus v3.0.
  17. ;This BIOS will function properly in most CP/M-2 systems,
  18. ;even those with the BIOS in PROM.
  19. ;
  20. ;FUNCTION:
  21. ;    This PROGRAM implements an UNBANKED, NON-HASHED,
  22. ;UNBUFFERED BIOS for CP/M Plus version 3.0.
  23. ;
  24. ;METHOD:
  25. ;    CP/M Plus allows many levels of sophistocation in
  26. ;the implementation of the BIOS.  At the highest levels,
  27. ;the BIOS allows CP/M Plus to manage a potentially large
  28. ;memory pool which acts like an instant access disk drive;
  29. ;a substantial performence enhancement.  At the lowest level,
  30. ;the performance of CP/M Plus is the same as that of CP/M-80
  31. ;version 2.2.  This interface program is a simple implementation
  32. ;of a CP/M Plus BIOS which operates as a parasite to the user's
  33. ;existing BIOS for CP/M-80 version 2.2.
  34. ;
  35. ;PURPOSE:
  36. ;    This BIOS allows the CP/M-80 v2.2 user to easily
  37. ;upgrade to CP/M Plus v3.0 and enjoy its logical enhancements
  38. ;at the same level of performance he has enjoyed with v2.2.
  39. ;This BIOS can be an end-point since system performance
  40. ;will be satisfactory.  For users who own the hardware
  41. ;required to implement hashing and buffering, this BIOS
  42. ;will serve as a welcome starting point for further enhancement.
  43. ;
  44. ;ORGANIZATION:
  45. ;    This BIOS is organized as follows:
  46. ;
  47. ;    CONSTANTS
  48. ;    CONFIGURATION CONSTANTS AND CONDITIONS  ***
  49. ;    EXTERNAL REFERENCES
  50. ;    PUBLIC DECLARATIONS    (NULL)
  51. ;    RAM DEFINITIONS
  52. ;    CP/M 2.2 LINKAGE EQUATES
  53. ;
  54. ;    CP/M PLUS JUMP TABLE
  55. ;    INITIALIZATION PROCESSES
  56. ;    LOCAL AND NULL PROCESSES
  57. ;    SIMPLE INDEXED PROCESSES
  58. ;    COMPLEX INDEXED PROCESSES
  59. ;    LOCAL SUBROUTINES
  60. ;    INITIALIZED STORAGE
  61. ;    UNINITIALIZED STORAGE
  62. ;    END
  63. ;
  64. ;    ***    edit these
  65. ;--------------------------------------------------------
  66. ;
  67. ;    OPERATIONAL COMMENTARY
  68. ;
  69. ;--------------------------------------------------------
  70. ;
  71. ;    Digital Research owes much of its success to the
  72. ;foresight of its operating system designers who have seen
  73. ;fit to make their products upward compatible with one
  74. ;another.  CP/M Plus is no exception, and so it is no
  75. ;surprise that the CP/M Plus BIOS shares many constructs
  76. ;with the earlier CP/M-80 v2.2.
  77. ;
  78. ;    The CP/M Plus BIOS implements 32 entry points in
  79. ;its jump table.  Of these, the first 17 correspond to the
  80. ;17 entries in the CP/M-80 v2.2 jump table.  14 of these
  81. ;are treated as identical to those in 2.2.  These index
  82. ;directly into the 2.2 jump table.  The remaining three in the
  83. ;2.2 set are BOOT, which is null, WBOOT, which loads CCP.COM,
  84. ;and SELDSK which creates all of the necessary disk data
  85. ;structures required by CP/M Plus based on those in the 2.2 BIOS.
  86. ;The remaining 15 entries in the CP/M Plus BIOS, with the
  87. ;single exception of MOVE, are implemented in one of
  88. ;the following ways:
  89. ;
  90. ;    1.)    null, simply return.
  91. ;    2.)    nearly null, do something really simple.
  92. ;    3.)    tell a white lie.
  93. ;
  94. ;--------------------------------------------------------
  95. ;
  96. ;    constants
  97. ;
  98. ;--------------------------------------------------------
  99. true    equ    -1
  100. false    equ    not true
  101. jmpop    equ    0c3h
  102. getch    equ    1
  103. print    equ    9
  104. open    equ    15
  105. readseq    equ    20
  106. dma    equ    26
  107. ;--------------------------------------------------------
  108. ;
  109. ;    configuration constants and conditions
  110. ;
  111. ;--------------------------------------------------------
  112. drives    equ    2        ;number of drives supported
  113. bios    equ    0e900h        ;address of your bios
  114. ldrbios    equ    true
  115. ;ldrbios    equ    false
  116. ;--------------------------------------------------------
  117. ;
  118. ;    external references
  119. ;
  120. ;--------------------------------------------------------
  121.     extrn    @civec, @covec, @aovec, @lovec, @bnkbf
  122.     extrn    @crdma
  123.     extrn    @crdsk,    @fx, @resel, @vinfo, @usrcd, @ermde
  124.     extrn    @date, @hour, @min, @sec, @mxtpa
  125. ;--------------------------------------------------------
  126. ;
  127. ;    public declarations
  128. ;
  129. ;--------------------------------------------------------
  130. ;
  131. ;currently null
  132. ;
  133. ;--------------------------------------------------------
  134. ;
  135. ;    ram definitions
  136. ;
  137. ;--------------------------------------------------------
  138. iobyte    equ    3
  139. tpa    equ    100h
  140. dffcb    equ    5ch
  141. stack80    equ    100h
  142. bootram    equ    0
  143. bdos    equ    5
  144. ccp    equ    tpa
  145. ;--------------------------------------------------------
  146. ;
  147. ;    cp/m v2.2 linkage equates
  148. ;
  149. ;--------------------------------------------------------
  150. boot80    equ    0
  151. warm80    equ    3
  152. cnst80    equ    6
  153. cnin80    equ    9
  154. cnot80    equ    12
  155. list80    equ    15
  156. punc80    equ    18
  157. redr80    equ    21
  158. home80    equ    24
  159. slds80    equ    27
  160. strk80    equ    30
  161. ssec80    equ    33
  162. sdma80    equ    36
  163. read80    equ    39
  164. writ80    equ    42
  165. lsta80    equ    45
  166. sctr80    equ    48
  167. ;--------------------------------------------------------
  168. ;
  169. ;    cp/m plus version 3.0 jump table
  170. ;
  171. ;--------------------------------------------------------
  172.     cseg
  173. ;    org    (bios-(200h+64*drives)) and 0ff00h
  174. ;
  175.     jmp    boot    ;arrive here from cold start load
  176. warmpt:
  177.     jmp    wboot    ;arrive here for warm start
  178.     jmp    const    ;return console input status
  179.     jmp    conin    ;read console character
  180.     jmp    conout    ;write conlole character
  181.     jmp    list    ;write list character
  182.     jmp    auxout    ;write aux character
  183.     jmp    auxin    ;read aux character
  184.     jmp    home    ;move to track zero on selected drive
  185.     jmp    seldsk    ;select disk drive
  186.     jmp    settrk    ;set track number
  187.     jmp    setsec    ;set sector number
  188.     jmp    setdma    ;set DMA address
  189.     jmp    read    ;read selected sector
  190.     jmp    write    ;write selected sector
  191.     jmp    listst    ;return list device status
  192.     jmp    sectrn    ;translate logical to physical sector number
  193.     jmp    conost    ;return console output status
  194.     jmp    auxist    ;return aux device input status
  195.     jmp    auxost    ;return aux device output status
  196.     jmp    devtbl    ;return address of character i/o table
  197.     jmp    devini    ;init character i/o devices
  198.     jmp    drvtbl    ;return address of disk drive table
  199.     jmp    multio    ;set number of consec. sec. to read/write
  200.     jmp    flush    ;flush user [de]blocking buffers
  201.     jmp    move    ;copy memory to memory
  202.     jmp    xmove    ;set banks for next move
  203.     jmp    selmem    ;select memory bank
  204.     jmp    setbnk    ;set bank for next DMA
  205.     jmp    userf    ;reserved for me.
  206.     jmp    wboot
  207.     jmp    wboot    ;reserved for DRI
  208. ;
  209. ;
  210. ;--------------------------------------------------------
  211. ;
  212. ;    initialization processes
  213. ;
  214. ;--------------------------------------------------------
  215. boot:
  216.     if    ldrbios
  217.     ret
  218.     endif
  219.     ;boot is null, falls thru to wboot
  220. wboot:
  221.     lxi    sp,stack80
  222. ;
  223. ;    initialize low memory jumps
  224. ;
  225.     lxi    h,warmpt
  226.     shld    bootram+1
  227.     lhld    @mxtpa
  228.     shld    bdos+1
  229.     mvi    a,jmpop
  230.     sta    bootram
  231.     sta    bdos
  232. ;
  233. ;    load ccp.com into tpa
  234. ;
  235.     mvi    b,36
  236.     lxi    h,dffcb
  237.     call    clear        ;clear fcb area in low ram
  238.     lxi    h,dffcb
  239.     mvi    m,1        ;drive a:
  240.     inx    h
  241.     lxi    d,ccpstg    ;'ccp     com'
  242.     lxi    b,11        ;length of a file name
  243.     call    move        ;move filename to fcb
  244.     lxi    d,dffcb
  245.     mvi    c,open
  246.     call    bdos        ;open ccp.com
  247.     ora    a
  248.     jnz    operr        ;if no error (
  249.     lxi    d,tpa        ;load into tpa
  250. ;
  251. ;    the load loop
  252. ;
  253. ldloop:
  254.     push    d        ;the current dma address
  255.     mvi    c,dma
  256.     call    bdos        ;set dma for next 128 byte read
  257.     lxi    d,dffcb
  258.     mvi    c,readseq
  259.     call    bdos        ;read file data to tpa ram
  260.     ora    a        ;test for complete
  261.     pop    d        ;restore dma address
  262.     jnz    gocpm        ;exit when past file end
  263.     lxi    h,128        ;advance dma address 128 bytes
  264.     dad    d
  265.     xchg
  266.     jmp    ldloop        ;loop
  267. ;
  268. ;
  269. gocpm:
  270.     cpi    1        ;only legal exit = past end of file
  271.     jnz    rderr
  272.     jmp    ccp        ;now turn it loose
  273. ;
  274. ;
  275. operr:
  276.     lxi    d,opnmsg    ;"BIOS can't open CCP.COM"
  277.     jmp    errs
  278. rderr:
  279.     lxi    d,errmsg    ;"BIOS has bad sector in CCP.COM"
  280. errs:
  281.     mvi    c,print
  282.     call    bdos        ;print the complaint
  283.     mvi    c,getch
  284.     call    bdos        ;wait for any key
  285.     jmp    wboot        ;try again and again
  286. ;--------------------------------------------------------
  287. ;
  288. ;    local and null processes
  289. ;
  290. ;--------------------------------------------------------
  291. conost:
  292. auxist:
  293. auxost:
  294.     mvi    a,true        ;the white lies
  295. devini:
  296. multio:
  297. xmove:
  298. selmem:
  299. setbnk:
  300. userf:
  301.     ret            ;the null routines
  302. flush:
  303.     xra    a        ;not implemented
  304.     ret
  305. devtbl:
  306.     lxi    h,-1        ;not implemented
  307.     ret
  308. drvtbl:
  309.     lxi    h,-2        ;no table, no hashing
  310.     ret
  311. move:
  312. ;    z80 users may code as:
  313. ;    xchg
  314. ;    db    0edh,0b0h    ;ldir
  315. ;    xchg
  316. ;    ret
  317. ;
  318.     ldax    d
  319.     mov    m,a
  320.     inx    h
  321.     inx    d
  322.     dcx    b
  323.     mov    a,b
  324.     ora    c
  325.     jnz    move
  326.     ret
  327. ;--------------------------------------------------------
  328. ;
  329. ;    simple indexed processes
  330. ;
  331. ;--------------------------------------------------------
  332. const    equ    bios+cnst80
  333. conin    equ    bios+cnin80
  334. conout    equ    bios+cnot80
  335. list    equ    bios+list80
  336. auxout    equ    bios+punc80
  337. auxin    equ    bios+redr80
  338. home    equ    bios+home80
  339. settrk    equ    bios+strk80
  340. setsec    equ    bios+ssec80
  341. setdma    equ    bios+sdma80
  342. read    equ    bios+read80
  343. write    equ    bios+writ80
  344. listst    equ    bios+lsta80
  345. sectrn    equ    bios+sctr80
  346. ;--------------------------------------------------------
  347. ;
  348. ;    complex indexed functions
  349. ;
  350. ;--------------------------------------------------------
  351. ;this routine functions as follows:
  352. ;    1.)    the requested drive is saved for use as index later
  353. ;    2.)    seldsk in bios 2.2 is called to set-up disk tables
  354. ;    3.)    the returned bios 2.2 dph address is saved
  355. ;    4.)    the saved drive number is used to index into a block
  356. ;        of length (drives * 64-bytes).  The 64-byte area
  357. ;        reserved for this drive is initially cleared (zeros).
  358. ;    5.)    using data taken from dph 2.2 returned by seldsk 2.2,
  359. ;        a new dph for 3.0 is constructed, with dpb and dirbcb.
  360. ;
  361. ;    like this:
  362. ;
  363. ;        dph:    25 bytes
  364. ;        null    7 bytes
  365. ;        dpb:    17 bytes
  366. ;        dirbcb:    15 bytes
  367. ;
  368. ;        the dph references dpb and dirbcb.  dirbcb references
  369. ;        the dirbuf from dph 2.2.  xlt, csv, alv are from dph2
  370. ;        dpb3 is copied directly from the dpb in your bios
  371. ;
  372. seldsk:
  373.     lxi    h,0        ;bad drive
  374.     mov    a,c        ;drive request
  375.     cpi    drives
  376.     rnc            ;exit if no space alloc for drive
  377.     mov    b,e        ;prev. selected bit
  378.     push    b        ;save drive request
  379.     call    bios+slds80    ;run seldsk 2.2
  380.     pop    b        ;restore drive request
  381.     mov    a,l
  382.     ora    h        ;test for illegal drive
  383.     rz            ;if legal_drive (
  384.     shld    dph2        ;save address of dph 2.2
  385.     mov    l,c        ;drive number
  386.     mvi    h,0
  387.     dad    h        ;*2
  388.     dad    h        ;*4
  389.     dad    h        ;*8
  390.     dad    h        ;*16
  391.     dad    h        ;*32
  392.     dad    h        ;*64...64 bytes per entry
  393.     lxi    d,tables    ;base of table space
  394.     dad    d        ;address of base block this drive
  395.     mov    a,b        ;selected bit
  396.     ani    1        ;lsb = 1 if previously selected
  397.     rnz            ;don't reinit if prev. sel.
  398.     shld    dph3        ;save address of new dph 3.0
  399.     mvi    b,64        ;bytes to clear
  400.     call    clear        ;initialize space
  401.     lhld    dph2
  402.     xchg
  403.     lhld    dph3
  404.     lxi    b,2
  405.     call    move        ;dph3.xlt
  406.     lxi    b,12        ;offset to dph3.csv
  407.     dad    b
  408.     xchg
  409.     lxi    b,10        ;offset to dph2.csv
  410.     dad    b
  411.     xchg
  412.     lxi    b,4        ;2 words
  413.     call    move        ;dph3.csv, alv
  414.     xchg            ;saving pointer to dph3.dirbcb
  415.     lxi    b,32+17        ;offset to bcb area
  416.     lhld    dph3        ;base
  417.     dad    b
  418.     push    h        ;saving pointer to dirbcb
  419.     xchg            ;restore pointer to dph3.dirbcb
  420.     mvi    a,-1        ;dirbcb is unused
  421.     stax    d        ;set dirbcb.drv to unused status
  422.     mov    m,e        ;
  423.     inx    h
  424.     mov    m,d        ;dph3.dirbcb <- dirbcb
  425.     inx    h
  426.     mvi    m,-1        ;
  427.     inx    h
  428.     mvi    m,-1        ;dph3.dtabcb <- empty
  429.     lhld    dph2
  430.     lxi    b,8        ;offset to dirbuf entry
  431.     dad    b
  432.     xchg            ;[de] is source
  433.     pop    h        ;restore pointer to dirbcb
  434.     lxi    b,10        ;offset to bufadr entry
  435.     dad    b
  436.     lxi    b,2        ;1 word
  437.     call    move        ;dirbcb.bufadr <- dirbuf2.2
  438.     xchg            ;[hl] points to dph2.dpb
  439.     mov    e,m        ;
  440.     inx    h
  441.     mov    d,m        ;read address of dpb2
  442.     lhld    dph3
  443.     lxi    b,12        ;offset to dpb within dph3
  444.     dad    b
  445.     push    h        ;points to dpb within dph3
  446.     lhld    dph3
  447.     lxi    b,32        ;offset to dpb3
  448.     dad    b
  449.     pop    b        ;restore pointer to dph3.dpb
  450.     mov    a,l
  451.     stax    b        ;
  452.     inx    b
  453.     mov    a,h
  454.     stax    b        ;dph3.dpb <- dpb3
  455.     lxi    b,15        ;bytes in dpb2
  456.     call    move        ;fill-in dpb3 from dpb2
  457.     if    ldrbios
  458.     lxi    h,tables+64    ;empty space in dph3 for drive b:
  459.     mvi    b,15        ;length of bcb
  460.     call    clear
  461.     lxi    h,tables+64+15    ;empty space past dtabcb
  462.     shld    tables+64+10    ;dtabcb.bufadr
  463.     lxi    h,tables+64    ;dtabcb address
  464.     shld    tables+20    ;dph3.dtabcb
  465.     mvi    m,-1        ;set dtabcb.drv to unused
  466.     endif
  467.     lhld    dph3        ;the big lie
  468.     ret            ; )
  469.  
  470. ;--------------------------------------------------------
  471. ;
  472. ;    local subroutines
  473. ;
  474. ;--------------------------------------------------------
  475. clear:
  476.     mvi    m,0
  477.     inx    h
  478.     dcr    b
  479.     jnz    clear
  480.     ret
  481. ;--------------------------------------------------------
  482. ;
  483. ;    initialized storage
  484. ;
  485. ;--------------------------------------------------------
  486. ccpstg:
  487.     db    'CCP     COM'
  488. opnmsg:
  489.     db    0dh,0ah,'BIOS can''t open CCP.COM $'
  490. errmsg:
  491.     db    0dh,0ah,'BIOS has bad sector in CCP.COM $'
  492. ;--------------------------------------------------------
  493. ;
  494. ;    uninitialized storage
  495. ;
  496. ;--------------------------------------------------------
  497.     dseg
  498. dph2    ds    2
  499. dph3    ds    2
  500. tables    ds    64*drives
  501.     end
  502. ;--------------------------------------------------------
  503. ;cp/m is a registered trademark of digital research, inc.
  504. ;you already knew that, but they wanted us to remind you.
  505. ;--------------------------------------------------------
  506.