home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol017 / spclmac.lib < prev    next >
Encoding:
Text File  |  1985-02-10  |  3.9 KB  |  168 lines

  1. ;    CP/M 2.0 disk re-definition library
  2. ;
  3. ;    Copyright (c) 1979
  4. ;    Digital Research
  5. ;    Box 579
  6. ;    Pacific Grove, CA
  7. ;    93950
  8. ;
  9. ;    Modified by:
  10. ;    Copyright (c) 1980
  11. ;    Robert M. White
  12. ;    H & W Computer Systems, Inc.
  13. ;    8530 Stonehaven
  14. ;    Boise, Idaho
  15. ;    83704
  16. ;
  17. ;
  18. ;    This set of macros provide necessary table
  19. ;    definitions for the use of the new BIOS
  20. ;    routines.
  21. ;
  22. ;
  23. ;        * * *  Disk Parameter Block  * * *
  24. ;    each parameter-list-i takes the form
  25. ;        dfc,ssc,nsc,bls,dks,dir,cks,ofs,xlt,[0]
  26. ;    where
  27. ;    dfc    is the Disk Format Code defined by DFOCO
  28. ;    ssc    is the physical host sector size 
  29. ;            (128,256,512,1024)
  30. ╗    nsπ    i≤ thσ number of physical sectors per track
  31. ;    bls    is the data block size (1024,2048,...,16384)
  32. ;    dks    is the disk size in bls increments (word)
  33. ;    dir    is the number of directory elements (word)
  34. ;    cks    is the number of dir elements to checksum
  35. ;    ofs    is the number of tracks to skip (word)
  36. ;    xlt    is the optional Sector Translation Table adr
  37. ;            (should be 0 if none)
  38. ;    [0]    is an optional 0 which forces 16K/directory entry
  39. ;
  40. ddb    macro    data,comment
  41. ;;    define a db statement
  42.     db    data        comment
  43.     endm
  44. ;
  45. ddw    macro    data,comment
  46. ;;    define a dw statement
  47.     dw    data        comment
  48.     endm
  49. ;
  50. ;
  51. DPB    macro    dfc,ssc,nsc,bls,dks,dir,cks,ofs,xlt,k16
  52. ;;    generate the block shift value
  53. blkval    set    bls/128    ;;number of sectors/block
  54. blkshf    set    0    ;;counts right 0's in blkval
  55. blkmsk    set    0    ;;fills with 1's from right
  56.     rept    16    ;;once for each bit position
  57.     if    blkval=1
  58.     exitm
  59.     endif
  60. ;;    otherwise, high order 1 not found yet
  61. blkshf    set    blkshf+1
  62. blkmsk    set    (blkmsk shl 1) or 1
  63. blkval    set    blkval/2
  64.     endm
  65. ;;    generate the extent mask byte
  66. blkval    set    bls/1024    ;;number of kilobytes/block
  67. extmsk    set    0    ;;fill from right with 1's
  68.     rept    16
  69.     if    blkval=1
  70.     exitm
  71.     endif
  72. ;;    otherwise more to shift
  73. extmsk    set    (extmsk shl 1) or 1
  74. blkval    set    blkval/2
  75.     endm
  76. ;;    may be double byte allocation
  77.     if    (dks) > 256
  78. extmsk    set    (extmsk shr 1)
  79.     endif
  80. ;;    may be optional [0] in last position
  81.     if    not nul k16
  82. extmsk    set    k16
  83.     endif
  84. ;;    now generate directory reservation bit vector
  85. dirrem    set    dir    ;;# remaining to process
  86. dirbks    set    bls/32    ;;number of entries per block
  87. dirblk    set    0    ;;fill with 1's on each loop
  88.     rept    16
  89.     if    dirrem=0
  90.     exitm
  91.     endif
  92. ;;    not complete, iterate once again
  93. ;;    shift right and add 1 high order bit
  94. dirblk    set    (dirblk shr 1) or 8000h
  95.     if    dirrem > dirbks
  96. dirrem    set    dirrem-dirbks
  97.     else
  98. dirrem    set    0
  99.     endif
  100.     endm
  101. ;;
  102. hstblk    set    ssc/128    ;;number of CP/M sectors
  103. ;;            ;;     in a host sector
  104. cpmspt    set    hstblk*nsc
  105.             ;;number of CP/M sectors
  106. ;;            ;;    per track
  107. secmsk    set    hstblk-1 ;;host sector mask
  108. secrem    set    hstblk
  109. secshf    set    0
  110.     rept    8
  111.     if    secrem=1
  112.     exitm
  113.     endif
  114. ;;    not complete, iterate once again
  115. ;;    shift right one position.
  116. secrem    set    (secrem shr 1)
  117. secshf    set    secshf+1
  118.     endm
  119. ;;
  120. ;;
  121. ;;        generate the DPB.
  122.     ddw    %cpmspt,<;# of CP/M sec/trk>
  123.     ddb    %blkshf,<;block shift>
  124.     ddb    %blkmsk,<;block mask>
  125.     ddb    %extmsk,<;extnt mask>
  126.     ddw    %(dks)-1,<;disk size-1>
  127.     ddw    %(dir)-1,<;directory max>
  128.     ddb    %dirblk shr 8,<;alloc0>
  129.     ddb    %dirblk and 0ffh,<;alloc1>
  130.     ddw    %(cks)/4,<;check size>
  131.     ddw    %ofs,<;offset>
  132.     ddb    %dfc,<;Disk Format Code>
  133.     ddw    %ssc,<;host sector size>
  134.     ddb    %secmsk,<;host sector mask>
  135.     ddb    %secshf,<;host sector shift value>
  136.     ddw    %xlt,<;Sector Xlat Table>
  137.     endm
  138. ;
  139. ;
  140. ;        * * * Register Address w/disp * * *
  141. rxad    macro    base,disp
  142.     if    not nul base
  143.     lhld    base        ;get base address.
  144.     endif
  145.     if    not nul disp
  146.     push    d        ;add in disp.
  147.     lxi    d,disp
  148.     dad    d
  149.     pop    d
  150.     endif
  151.     endm
  152. ;
  153. ;
  154. ;        * * *  Load Register w/disp  * * *
  155. rxld    macro    reg,base,disp
  156.     rxad    base,disp
  157.     mov    reg,m        ;get the value.
  158.     endm
  159. ;
  160. ;
  161. ;        * * *  Load Double Register w/disp  * * *
  162. rxdld    macro    regpr,base,disp
  163.     rxad    base,disp
  164.     mov    regpr+1,m    ;get low byte.
  165.     inx    h
  166.     mov    regpr,m        ;get high byte.
  167.     endm
  168.