home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / rcpm / section2.aqm / SECTION2.ASM
Encoding:
Assembly Source File  |  1985-02-09  |  11.9 KB  |  485 lines

  1.  
  2. ;    *        *
  3. ;    *  SECTION.ASM    *
  4. ;    *     v2.0    *
  5. ;    *        *
  6. ;    *****************
  7. ;
  8. ; 06/27/82 by Ron Fowler, Westland, Michigan
  9. ; 02/26/84 fixed user specification in section table.
  10. ;       Now requires 2-digit user spec. SFK
  11. ;
  12. ;
  13. ; This program is intended for RCPM systems where
  14. ; files are grouped into drive/user area by their
  15. ; classification.  This program implements a naming
  16. ; convention, whereby a caller can move into a
  17. ; section by typing its name, rather than the random
  18. ; searching formerly needed.
  19. ;
  20. ; Syntax is:  SECTION [<section-name>]
  21. ;
  22. ; If section-name is omitted, a short list of
  23. ; available sections is printed. The special
  24. ; form "SECTION ?" prints the detailed description
  25. ; of each section.
  26. ;
  27. ; You have to fill in the sections table
  28. ; (located near the end of this program) for your
  29. ; particular system.
  30. ;
  31. ;----< Examples of use: >-----
  32. ;
  33. ; A0>SECTION ATARI    ;changes drive/user to atari area
  34. ; B4>SECTION MBASIC    ;changes drive/user to mbasic area
  35. ; A6>SECTION        ;prints short list of sections
  36. ; A9>SECTION ?        ;prints the detailed list
  37. ;
  38. false    equ    0    ;define truth and falsehood
  39. true    equ    not false
  40. ;
  41. ; the following equates may be
  42. ; customized to your preference
  43. ;
  44. descol    equ    10        ;column # where description begins
  45.                 ;(in detailed list) (should be greater
  46.                 ;than longest section name) (but small
  47.                 ;enuf so display is not too long)
  48. perlin    equ    4        ;names printed per line in short list
  49. tabpos    equ    9        ;tab stops (set mod tabpos)
  50.                 ;should be at least one greater than
  51.                 ;longest section name.
  52. turbo    equ    false        ;set TRUE if you'er running TurboDOS
  53. ;
  54. ; o/s conventions
  55. ;
  56. cpbase    equ    0        ;set to 4200H for Heath
  57. ccpdrv    equ    cpbase+4    ;ccp user/drive storage loc
  58. bdos    equ    cpbase+5    ;system entry point
  59. dfcb    equ    cpbase+5CH    ;default file control block
  60. dbuf    equ    cpbase+80H    ;default buffer
  61. tpa    equ    cpbase+100H    ;base of transient program area
  62. coninf    equ    1        ;system call, get console char
  63. conotf    equ    2        ;system call, console output
  64. printf    equ    9        ;system call, print cons string
  65. cstsf    equ    11        ;system call, get console status
  66. setdrv    equ    14        ;system call, set/drive system call
  67. getdrv    equ    25        ;system call, get drive # system call
  68. gsuser    equ    32        ;system call, get/set user number
  69. ;
  70. ; character definitions
  71. ;
  72. cr    equ    13        ;carriage-return code
  73. lf    equ    10        ;linefeed code
  74. ;
  75. ; code begins....
  76. ;
  77.     org    tpa
  78. ;
  79. ;
  80. pbase:    lxi    h,0        ;save system stack
  81.     dad    sp
  82.     shld    spsave
  83. ;
  84.     if    not turbo
  85.     lxi    sp,stack    ;load local stack
  86.     mvi    c,getdrv    ;get current drive #
  87.     call    bdos
  88.     push    psw        ;save it
  89.     sta    newdrv        ;two ways
  90.     endif
  91. ;
  92.     call    sect        ;perform the section function
  93. ;
  94.     if    not turbo    ;turbodos doesn't need this stuff
  95.     lda    newdrv        ;get newly logged drive
  96.     mov    b,a        ;save for comparison
  97.     pop    psw        ;get old logged drive
  98.     cmp    b        ;did logged drive change?
  99.     jnz    cpbase        ;then relog with warm boot
  100.     endif
  101. ;
  102.     rst    0
  103. ;
  104. ; scan cmd line...if an arg exists, attempt to
  105. ; match it in the table.  If no arg, dump a list
  106. ; of available sections.
  107. ;
  108. sect:    lda    dfcb+1        ;is there a cmd-line arg?
  109.     cpi    ' '
  110.     jz    prnqk        ;then go print sections out
  111.     cpi    '?'        ;wants detailed list?
  112.     jz    prntbl        ;then go do it
  113.     lxi    h,dbuf        ;something there, scan to it
  114. scanbk: inx    h        ;  ignoring blanks
  115.     mov    a,m
  116.     cpi    ' '
  117.     jz    scanbk
  118.     lxi    d,table     ;point de to the section table
  119. loop:    push    h        ;save cmd line arg pointer
  120. eloop:    ldax    d        ;test entry against table
  121.     cpi    1        ;end of entry marker?
  122.     jnz    noend        ;jump if not
  123.     mov    a,m        ;yes, did user cmd terminate also?
  124.     ora    a
  125.     jz    match        ;then declare a match
  126.     jmp    nomat        ;else declare a mismatch
  127. noend:    cmp    m
  128.     jnz    nomat        ;skip if no match
  129.     inx    h        ;continue with comparison
  130.     inx    d
  131.     jmp    eloop
  132. ;
  133. ; here when an entry didn't match
  134. ;
  135. nomat:    ldax    d
  136.     ora    a        ;entry terminator?
  137.     inx    d
  138.     jnz    nomat        ;scan through it
  139.     pop    h        ;restore cmd line arg pntr
  140.     inx    d        ;end of entry, skip over user #
  141.     inx    d
  142.     inx    d        ;and drive
  143.     ldax    d        ;end of table?
  144.     ora    a        ;(terminated by 0)
  145.     jnz    loop        ;go scan another if not
  146. ;
  147. ; here when no match can be found
  148. ;
  149.     lxi    d,matmsg    ;print out no-match message
  150.     mvi    c,printf
  151.     call    bdos
  152.     jmp    prnqk        ;go give short list
  153. ;
  154. ; here when a match is found
  155. ;
  156. match:    xchg            ;hl==> user #
  157. scmat:    inx    h        ;scan past description
  158.     mov    a,m        ;looking for terminating null
  159.     ora    a
  160.     jnz    scmat
  161.     inx    h        ;skip over terminator
  162.     mov    a,m        ;fetch user #
  163.     sui    '0'        ;subtract ascii bias
  164. ;
  165. ; the following patch allows 2-digit user numbers. it
  166. ; is the user's responsibility to comply with CP/M
  167. ; user number conventions.
  168. ;
  169.     cpi    1
  170.     jnz    no10
  171.     mvi    a,10
  172. no10:    mov    e,a
  173.     inx    h
  174.     mov    a,m
  175.     sui    '0'
  176.     add    e
  177.     mov    e,a
  178.     inx    h        ;point hl to drive #
  179.     push    d        ;save user #
  180.     push    h        ;and pointer
  181.     mvi    c,gsuser    ;set user number
  182.     call    bdos
  183.     pop    h        ;restore pointer to drive
  184.     mov    a,m        ;fetch drive
  185.     sui    'A'        ;subtract ascii bias
  186.     sta    newdrv        ;set new logged drive
  187.     pop    d        ;restore user number in e
  188.     mov    d,a        ;save drive #
  189.     mov    a,e        ;fetch user number
  190.     rlc            ;rotate to high nybble
  191.     rlc
  192.     rlc
  193.     rlc
  194.     ora    d        ;"or" in the drive
  195.     sta    ccpdrv        ;save for ccp use
  196.     mvi    c,setdrv    ;...have to set drive explicitly
  197.     mov    e,d        ;get drive in e
  198.     call    bdos        ;set the drive
  199.     pop    h        ;clear garbage from stack
  200.     ret            ;all done
  201. ;
  202. ; message printed when match failed
  203. ;
  204. matmsg: db    cr,lf,'++ Entry not found ++'
  205.     db    cr,lf,cr,lf,'$'
  206. matms2: db    cr,lf,'Type "SECTION ?" for detailed list'
  207.     db    cr,lf,'      of available sections.',cr,lf
  208.     db    cr,lf,'Type "SECTION <section-name>" to log'
  209.     db    cr,lf,'      into a particular section.'
  210.     db    cr,lf,'$'
  211. ;
  212. ; print "quick list"
  213. ;
  214. prnqk:    lxi    d,tblmsg
  215.     mvi    c,printf
  216.     call    bdos
  217.     lxi    h,table     ;print abbreviated list
  218. qloop:    mvi    b,perlin    ;get names-per-line counter
  219. qloop2: mov    a,m        ;end of table?
  220.     ora    A
  221.     jz    qkend        ;then go print end msg
  222.     call    prathl        ;else print the name
  223. qscan:    mov    a,m        ;scan to description terminator
  224.     inx    h        ;(this effectively ignores
  225.     ora    a        ; the description)
  226.     jnz    qscan
  227.     inx    h        ;skip over user #
  228.     inx    h
  229.     inx    h        ;and drive #
  230.     dcr    b        ;count down line entry counter
  231.     jnz    qtab        ;go tab if line not full
  232.     call    crlf        ;else turn up new line
  233.     jmp    qloop        ;and continue
  234. ;
  235. ; tab between entry names
  236. ;
  237. qtab:    mvi    a,' '        ;seperate names with tabs
  238.     call    type
  239.     lda    column        ;get column #
  240. qsub:    sui    tabpos        ;test tab position
  241.     jz    qloop2        ;continue if at a tab position
  242.     jnc    qsub        ;convert mod tabpos
  243.     jmp    qtab        ;keep tabbing
  244. ;
  245. qkend:    call    crlf        ;do newline
  246.     lxi    d,matms2    ;print ending message
  247.     mvi    c,printf
  248.     call    bdos
  249.     call    crlf
  250.     ret
  251. ;
  252. ; here to print out a list of available section numbers
  253. ;
  254. prntbl: lxi    d,tblmsg    ;print heading message
  255.     mvi    c,printf
  256.     call    bdos
  257.     call    crlf        ;turn up new line
  258.     lxi    h,table
  259. prloop: mov    a,m        ;end-of-table?
  260.     ora    a
  261.     rz            ;then all done
  262.     call    prathl        ;print the name
  263. tab:    mvi    a,'.'        ;tab over with leader
  264.     call    type
  265.     lda    column        ;get column
  266.     cpi    descol        ;at description column yet?
  267.     jc    tab        ;then keep tabbing
  268.     call    prathl        ;print description
  269.     inx    h        ;skip over user #
  270.     inx    h        ;and drive number
  271.     call    crlf        ;turn up new line
  272.     jmp    prloop        ;and continue
  273. ;
  274. ; print message @hl until null or 01 binary
  275. ;
  276. prathl: mov    a,m        ;fetch char
  277.     inx    h        ;point past it
  278.     ora    a        ;null?
  279.     rz            ;then done
  280.     cpi    1        ;1 also terminates
  281.     rz
  282.     call    type        ;nope, print it
  283.     call    break        ;check for console abort
  284.     jmp    prathl
  285. ;
  286. ; test for request from console to stop (^C)
  287. ;
  288. break:    push    h        ;save 'em all
  289.     push    d
  290.     push    b
  291.     mvi    c,cstsf     ;get console sts request
  292.     call    bdos
  293.     ora    a        ;anything waiting?
  294.     jz    brback        ;exit if not
  295.     mvi    c,coninf    ;there, is, get it
  296.     call    bdos
  297.     cpi    'S'-64        ;got pause request?
  298.     mvi    c,coninf
  299.     cz    bdos        ;then wait for another character
  300.     cpi    'C'-64        ;got abort request?
  301.     jz    quit        ;then go abort
  302. brback: pop    b        ;else restore and return
  303.     pop    d
  304.     pop    h
  305.     ret
  306. ;
  307. ; request from console to abort
  308. ;
  309. quit:    lxi    d,qmesg     ;tell of quit
  310.     mvi    c,printf
  311.     call    bdos
  312.     lhld    spsave        ;get stack pointer
  313.     sphl
  314.     ret
  315. ;
  316. qmesg:    db    cr,lf,'++ Aborted ++',cr,lf,'$'
  317. ;
  318. ; turn up a new line on display
  319. ;
  320. crlf:    mvi    a,cr        ;print a return
  321.     call    type
  322.     mvi    a,lf        ;get lf, fall into type
  323. ;
  324. ; Routine to print char in A on console,
  325. ; while maintaining column number. 
  326. ;
  327. type:    push    h        ;save everybody
  328.     push    d
  329.     push    b
  330.     mov    e,a        ;align char for printing
  331.     push    psw        ;save char
  332.     mvi    c,conotf
  333.     call    bdos        ;print it
  334.     pop    psw        ;restore char
  335.     lxi    h,column    ;bump column counter
  336.     cpi    lf        ;linefeed doesn't chang column
  337.     jz    nochg
  338.     inr    m
  339.     cpi    cr        ;carriage-return zeroes it
  340.     jnz    nochg        ;skip if not cr
  341.     mvi    m,0        ;is, zero column
  342. nochg:    pop    b        ;restore & return
  343.     pop    d
  344.     pop    h
  345.     ret
  346. ;
  347. ; dump heading message
  348. ;
  349. tblmsg: db    cr,lf,'Available sections are:',cr,lf,'$'
  350.  
  351. ;
  352. ;
  353. ; variables
  354. ;
  355. spsave: dw    0        ;stack-pointer save
  356. column: db    0        ;current column #
  357. newdrv: db    0        ;new drive # to log
  358.     ds    20        ;the stack
  359. ;
  360. stack    equ    $        ;define it
  361. ;
  362. ;
  363. ;
  364. ;
  365. ; SECTIONS TABLE (located at end for easy patching with DDT)
  366. ;
  367. ; This is the table that defines the sections.    Entry format is:
  368. ;
  369. ;    <name>,sep,<description>,null,user,drive
  370. ;
  371. ; where <name>           is the section name
  372. ;    sep           is a binary 1 used to terminate the match test
  373. ;    <description>  is a one-line-or-less comment printed when
  374. ;               the list is dumped.  Match testing terminates
  375. ;               before this field.
  376. ;    null           is a binary 0 used to terminate the description
  377. ;    user           is the user number (00-15) of the section (ascii)
  378. ;    drive           is the drive (A-P) number of the section (ascii)
  379. ;
  380. ; the table ends with a <name> of zero (binary).
  381. ;
  382. ; Note: be sure to make section names ALL-CAPS, because the
  383. ;    CCP converts command-line arguments to capitals. The
  384. ;    description may be in lower case, since it has nothing
  385. ;    to do with the matching process.
  386. ; Also: although the drive and user # is in ascii (for convenience
  387. ;    in setting up the table), be sure to use caps for the
  388. ;    drive designation.  No error checking is done on the values.
  389. ;
  390. table:    db    'SYSTEM',1,'System and Help',0
  391.     db    '00A'    ;user 0, drive A
  392. ;
  393.     db    'HELP',1,'HELP files',0
  394.     db    '01A'    ;user 1, drive A
  395. ;
  396.     db    'UTIL1',1,'Misc. utilities',0
  397.     db    '02A'    ;user 2, drive A
  398. ;
  399.     db    'MISC1',1,'Miscellaneous',0
  400.     db    '03A'    ;user 3, drive A
  401. ;
  402.     db    'MODEMS',1,'Modem transfer pgms (NOT MDM7)',0
  403.     db    '04A'    ;user 4, drive A
  404. ;
  405.     db    'NSTAR',1,'North Star files',0
  406.     db    '00B'    ;user 0, drive B
  407. ;
  408.     db    'RCPM',1,'Remote CP/M system software',0
  409.     db    '01B'    ;user 6, drive A
  410. ;
  411.     db    'LANG',1,'Programming languages',0
  412.     db    '02B'    ;user 7, drive A
  413. ;
  414.     db    'DIRS',1,'Directory utilities',0
  415.     db    '03B'    ;user 8, drive A
  416. ;
  417.     db    'MISC2',1,'Misc. files',0
  418.     db    '04B'    ;user 9, drive A
  419. ;
  420.     db    'MISC3',1,'Misc. files',0
  421.     db    '00C'    ;user 0 drive B
  422. ;
  423.     db    'SQ/USQ',1,'ASM versions of SQ,USQ etc',0
  424.     db    '01C'    ;user 1, drive B
  425. ;
  426.     db    'HAMS',1,'Ham radio files',0
  427.     db    '02C'    ;user 2, drive B
  428. ;
  429.     db    'ADVENT',1,'Adventure',0
  430.     db    '03C'    ;user 3, drive B
  431. ;
  432.     db    'PICTURE',1,'Printer art',0
  433.     db    '04C'    ;user 4, drive B
  434. ;
  435.     db    'SYSLIB',1,'Rick Conn''s SYSLIB files',0
  436.     db    '00D'    ;user 5, drive B
  437. ;
  438.     db    'BDSC',1,'BDS C source files',0
  439.     db    '01D'
  440. ;
  441.     db    'CPM86',1,'CP/M 86 files',0
  442.     db    '02D'
  443. ;
  444.     db    'IBMPC',1,'Files for the IBM PC',0
  445.     db    '03D'
  446. ;
  447.     db    'TEXT',1,'Editors, text processors',0
  448.     db    '04D'    ;user 2, drive C
  449. ;
  450.     db    'NEWSTUFF',1,'New files (uploads)',0
  451.     db    '00E'    ;user 3, drive C
  452. ;
  453.     db    'DISKUTL',1,'Disk utilities',0
  454.     db    '01E'    ;user 2, drive C
  455. ;
  456.     db    'CPM+',1,'CP/M plus files',0
  457.     db    '02E'    ;user 2, drive C
  458. ;
  459.     db    'ZCPR2-I',1,'ZCPR2 files I',0
  460.     db    '03E'    ;user 2, drive C
  461. ;
  462.     db    'UTIL2',1,'Utilities',0
  463.     db    '04E'    ;user 2, drive C
  464. ;
  465.     db    'MDM7',1,'MDM7 files',0
  466.     db    '00F'    ;user 2, drive C
  467. ;
  468.     db    'FORTRAN',1,'F80 files',0
  469.     db    '01F'    ;user 2, drive C
  470. ;
  471.     db    'MODULES',1,'Linkable modules for M80/RMAC',0
  472.     db    '02F'    ;user 2, drive C
  473. ;
  474.     db    'ZCPR2-II',1,'All ZCPR2 files (less HELP)',0
  475.     db    '03F'    ;user 2, drive C
  476. ;
  477.     db    'BASIC',1,'What can I say...',0
  478.     db    '04F'    ;user 2, drive C
  479. ;
  480.     db    0        ;<<== end of table
  481. ;
  482. ; -----< end of SECTIONS table>-----
  483. ;
  484.     end    pbase        ;that's all.
  485.