home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol179 / goto.aqm / GOTO.ASM
Encoding:
Assembly Source File  |  1985-02-10  |  11.0 KB  |  412 lines

  1. ;    *****************
  2. ;    *  CD.ASM    *
  3. ;    *     v1.0    *
  4. ;    *****************
  5. ; 03/15/83 renamed GOTO.ASM by C.J. Thompson
  6. ; 03/08/83 modified into "CD" by E. Jensen
  7. ; 06/27/82 by Ron Fowler, Westland, Michigan
  8. ;
  9. ; This program is intended for RCPM systems where
  10. ; files are grouped into drive/user area by their
  11. ; classification.  This program implements a naming
  12. ; convention, whereby a caller can move into a
  13. ; section by typing its name, rather than the random
  14. ; searching formerly needed.
  15. ;
  16. ; Syntax is:  GOTO [<section-name>]
  17. ;
  18. ; If section-name is omitted, a short list of
  19. ; available sections is printed. The special
  20. ; form "GOTO ?" prints the detailed description
  21. ; of each section.
  22. ;
  23. ; You have to fill in the sections table
  24. ; (located near the end of this program) for your
  25. ; particular system.
  26. ;
  27. ;----< Examples of use: >-----
  28. ;    
  29. ; A0> GOTO ATARI    ;changes drive/user to atari area
  30. ; B4> GOTO MBASIC    ;changes drive/user to mbasic area
  31. ; A6> GOTO        ;prints short list of sections
  32. ; A9> GOTO ?        ;prints the detailed list
  33. ;
  34. false    equ    0    ;define truth and falsehood
  35. true    equ    not false
  36. ;
  37. ; the following equates may be
  38. ; customized to your preference
  39. ;
  40. descol    equ    15        ;column # where description begins
  41.                 ;(in detailed list) (should be greater
  42.                 ;than longest section name) (but small
  43.                 ;enuf so display is not too long)
  44. perlin    equ    8        ;names printed per line in short list
  45. tabpos    equ    8        ;tab stops (set mod tabpos)
  46.                 ;should be at least one greater than
  47.                 ;longest section name.
  48. turbo    equ    false        ;set TRUE if you'er running TurboDOS
  49. ;
  50. ; o/s conventions
  51. ;
  52. ècpbase    equ    0        ;set to 4200H for Heath
  53. ccpdrv    equ    cpbase+4    ;ccp user/drive storage loc
  54. bdos    equ    cpbase+5    ;system entry point
  55. dfcb    equ    cpbase+5CH    ;default file control block
  56. dbuf    equ    cpbase+80H    ;default buffer
  57. tpa    equ    cpbase+100H    ;base of transient program area
  58. coninf    equ    1        ;system call, get console char
  59. conotf    equ    2        ;system call, console output
  60. printf    equ    9        ;system call, print cons string
  61. cstsf    equ    11        ;system call, get console status
  62. setdrv    equ    14        ;system call, set/drive system call
  63. getdrv    equ    25        ;system call, get drive # system call
  64. gsuser    equ    32        ;system call, get/set user number
  65. ;
  66. ; character definitions
  67. ;
  68. cr    equ    13        ;carriage-return code
  69. lf    equ    10        ;linefeed code
  70. ;
  71. ; code begins....
  72. ;
  73.     org    tpa
  74. ;
  75. ;
  76. pbase:    lxi    h,0        ;save system stack
  77.     dad    sp
  78.     shld    spsave
  79.     lxi    sp,stack    ;load local stack
  80. ;
  81.     if    not turbo    ;cp/m, get drive #
  82.     mvi    c,getdrv    ;get current drive #
  83.     call    bdos
  84.     push    psw        ;save it
  85.     sta    newdrv        ;two ways
  86.     endif
  87. ;
  88.     call    sect        ;perform the section function
  89. ;
  90.     if    not turbo    ;turbodos doesn't need this stuff
  91.     lda    newdrv        ;get newly logged drive
  92.     mov    b,a        ;save for comparison
  93.     pop    psw        ;get old logged drive
  94.     cmp    b        ;did logged drive change?
  95.     jnz    cpbase        ;then relog with warm boot
  96.     endif
  97. ;
  98.     lhld    spsave        ;else restore stack
  99.     sphl
  100.     ret            ;to system...
  101. ;
  102. ; scan cmd line...if an arg exists, attempt to
  103. ; match it in the table.  If no arg, dump a list
  104. ; of available sections.
  105. ;
  106. sect:    lda    dfcb+1        ;is there a cmd-line arg?
  107. è    cpi    ' '
  108.     jz    prnqk        ;then go print sections out
  109.     cpi    '?'        ;wants detailed list?
  110.     jz    prntbl        ;then go do it
  111.     lxi    h,dbuf        ;something there, scan to it
  112. scanbk: inx    h        ;  ignoring blanks
  113.     mov    a,m
  114.     cpi    ' '
  115.     jz    scanbk
  116.     lxi    d,table     ;point de to the section table
  117. loop:    push    h        ;save cmd line arg pointer
  118. eloop:    ldax    d        ;test entry against table
  119.     cpi    1        ;end of entry marker?
  120.     jnz    noend        ;jump if not
  121.     mov    a,m        ;yes, did user cmd terminate also?
  122.     ora    a
  123.     jz    match        ;then declare a match
  124.     jmp    nomat        ;else declare a mismatch
  125. noend:    cmp    m
  126.     jnz    nomat        ;skip if no match
  127.     inx    h        ;continue with comparison
  128.     inx    d
  129.     jmp    eloop
  130. ;
  131. ; here when an entry didn't match
  132. ;
  133. nomat:    ldax    d
  134.     ora    a        ;entry terminator?
  135.     inx    d
  136.     jnz    nomat        ;scan through it
  137.     pop    h        ;restore cmd line arg pntr
  138.     inx    d        ;end of entry, skip over user #
  139.     inx    d        ;and drive
  140.     ldax    d        ;end of table?
  141.     ora    a        ;(terminated by 0)
  142.     jnz    loop        ;go scan another if not
  143. ;
  144. ; here when no match can be found
  145. ;
  146.     lxi    d,matmsg    ;print out no-match message
  147.     mvi    c,printf
  148.     call    bdos
  149.     jmp    prnqk        ;go give short list
  150. ;
  151. ; here when a match is found
  152. ;
  153. match:    xchg            ;hl==> user #
  154. scmat:    inx    h        ;scan past description
  155.     mov    a,m        ;looking for terminating null
  156.     ora    a
  157.     jnz    scmat
  158.     inx    h        ;skip over terminator
  159.     mov    a,m        ;fetch user #
  160.     sui    '0'        ;subtract ascii bias
  161.     mov    e,a
  162. è    inx    h        ;point hl to drive #
  163.     push    d        ;save user #
  164.     push    h        ;and pointer
  165.     mvi    c,gsuser    ;set user number
  166.     call    bdos
  167.     pop    h        ;restore pointer to drive
  168.     mov    a,m        ;fetch drive
  169.     sui    'A'        ;subtract ascii bias
  170.     sta    newdrv        ;set new logged drive
  171.     pop    d        ;restore user number in e
  172.     mov    d,a        ;save drive #
  173.     mov    a,e        ;fetch user number
  174.     rlc            ;rotate to high nybble
  175.     rlc
  176.     rlc
  177.     rlc
  178.     ora    d        ;"or" in the drive
  179.     sta    ccpdrv        ;save for ccp use
  180. ;
  181.     if    turbo        ;if turbodos...
  182.     mvi    c,setdrv    ;...have to set drive explicitly
  183.     mov    e,d        ;get drive in e
  184.     call    bdos        ;set the drive
  185.     endif
  186. ;
  187.     pop    h        ;clear garbage from stack
  188.     ret            ;all done
  189. ;
  190. ; message printed when match failed
  191. ;
  192. matmsg: db    cr,lf,'++ Entry not found ++'
  193.     db    cr,lf,cr,lf,'$'
  194. matms2:    db    cr,lf,'Type  "GOTO <section-name>" '
  195.     db    ' or  "GOTO ?"  for definition of sections.'
  196.     db    '$'
  197. ;
  198. ; print "quick list"
  199. ;
  200. prnqk:    lxi    d,tblmsg
  201.     mvi    c,printf
  202.     call    bdos
  203.     lxi    h,table     ;print abbreviated list
  204. qloop:    mvi    b,perlin    ;get names-per-line counter
  205. qloop2: mov    a,m        ;end of table?
  206.     ora    a
  207.     jz    qkend        ;then go print end msg
  208.     call    prathl        ;else print the name
  209. qscan:    mov    a,m        ;scan to description terminator
  210.     inx    h        ;(this effectively ignores
  211.     ora    a        ; the description)
  212.     jnz    qscan
  213.     inx    h        ;skip over user #
  214.     inx    h        ;and drive #
  215. è    dcr    b        ;count down line entry counter
  216.     jnz    qtab        ;go tab if line not full
  217.     call    crlf        ;else turn up new line
  218.     jmp    qloop        ;and continue
  219. ;
  220. ; tab between entry names
  221. ;
  222. qtab:    mvi    a,' '        ;seperate names with tabs
  223.     call    type
  224.     lda    column        ;get column #
  225. qsub:    sui    tabpos        ;test tab position
  226.     jz    qloop2        ;continue if at a tab position
  227.     jnc    qsub        ;convert mod tabpos
  228.     jmp    qtab        ;keep tabbing
  229. ;
  230. qkend:    call    crlf        ;do newline
  231.     lxi    d,matms2    ;print ending message
  232.     mvi    c,printf
  233.     call    bdos
  234.     call    crlf
  235.     ret
  236. ;
  237. ; here to print out a list of available section numbers
  238. ;
  239. prntbl: lxi    d,tblmsg    ;print heading message
  240.     mvi    c,printf
  241.     call    bdos
  242.     call    crlf        ;turn up new line
  243.     lxi    h,table
  244. prloop: mov    a,m        ;end-of-table?
  245.     ora    a
  246.     rz            ;then all done
  247.     call    prathl        ;print the name
  248. tab:    mvi    a,'.'        ;tab over with leader
  249.     call    type
  250.     lda    column        ;get column
  251.     cpi    descol        ;at description column yet?
  252.     jc    tab        ;then keep tabbing
  253.     call    prathl        ;print description
  254.     inx    h        ;skip over user #
  255.     inx    h        ;and drive number
  256.     call    crlf        ;turn up new line
  257.     jmp    prloop        ;and continue
  258. ;
  259. ; print message @hl until null or 01 binary
  260. ;
  261. prathl: mov    a,m        ;fetch char
  262.     inx    h        ;point past it
  263.     ora    a        ;null?
  264.     rz            ;then done
  265.     cpi    1        ;1 also terminates
  266.     rz
  267.     call    type        ;nope, print it
  268.     call    break        ;check for console abort
  269.     jmp    prathl
  270. è;
  271. ; test for request from console to stop (^C)
  272. ;
  273. break:    push    h        ;save 'em all
  274.     push    d
  275.     push    b
  276.     mvi    c,cstsf     ;get console sts request
  277.     call    bdos
  278.     ora    a        ;anything waiting?
  279.     jz    brback        ;exit if not
  280.     mvi    c,coninf    ;there, is, get it
  281.     call    bdos
  282.     cpi    'S'-64        ;got pause request?
  283.     mvi    c,coninf
  284.     cz    bdos        ;then wait for another character
  285.     cpi    'C'-64        ;got abort request?
  286.     jz    quit        ;then go abort
  287. brback: pop    b        ;else restore and return
  288.     pop    d
  289.     pop    h
  290.     ret
  291. ;
  292. ; request from console to abort
  293. ;
  294. quit:    lxi    d,qmesg     ;tell of quit
  295.     mvi    c,printf
  296.     call    bdos
  297.     lhld    spsave        ;get stack pointer
  298.     sphl
  299.     ret
  300. ;
  301. qmesg:    db    cr,lf,'++ Aborted ++',cr,lf,'$'
  302. ;
  303. ; turn up a new line on display
  304. ;
  305. crlf:    mvi    a,cr        ;print a return
  306.     call    type
  307.     mvi    a,lf        ;get lf, fall into type
  308. ;
  309. ; Routine to print char in A on console,
  310. ; while maintaining column number. 
  311. ;
  312. type:    push    h        ;save everybody
  313.     push    d
  314.     push    b
  315.     mov    e,a        ;align char for printing
  316.     push    psw        ;save char
  317.     mvi    c,conotf
  318.     call    bdos        ;print it
  319.     pop    psw        ;restore char
  320.     lxi    h,column    ;bump column counter
  321.     cpi    lf        ;linefeed doesn't chang column
  322.     jz    nochg
  323.     inr    m
  324.     cpi    cr        ;carriage-return zeroes it
  325. è    jnz    nochg        ;skip if not cr
  326.     mvi    m,0        ;is, zero column
  327. nochg:    pop    b        ;restore & return
  328.     pop    d
  329.     pop    h
  330.     ret
  331. ;
  332. ; dump heading message
  333. ;
  334. tblmsg: db    cr,lf,'Available sections are:',cr,lf,lf,'$'
  335.  
  336. ;
  337. ;
  338. ; variables
  339. ;
  340. spsave: dw    0        ;stack-pointer save
  341. column: db    0        ;current column #
  342. newdrv: db    0        ;new drive # to log
  343.     ds    20        ;the stack
  344. ;
  345. stack    equ    $        ;define it
  346. ;
  347. ;
  348. ;
  349. ;
  350. ; SECTIONS TABLE (located at end for easy patching with DDT)
  351. ;
  352. ; This is the table that defines the sections.    Entry format is:
  353. ;
  354. ;    <name>,sep,<description>,null,user,drive
  355. ;
  356. ; where <name>           is the section name
  357. ;    sep           is a binary 1 used to terminate the match test
  358. ;    <description>  is a one-line-or-less comment printed when
  359. ;               the list is dumped.  Match testing terminates
  360. ;               before this field.
  361. ;    null           is a binary 0 used to terminate the description
  362. ;    user           is the user number (0-F) of the section (ascii)
  363. ;    drive           is the drive (A-P) number of the section (ascii)
  364. ;
  365. ; the table ends with a <name> of zero (binary).
  366. ;
  367. ; Note: be sure to make section names ALL-CAPS, because the
  368. ;    CCP converts command-line arguments to capitals. The
  369. ;    description may be in lower case, since it has nothing
  370. ;    to do with the matching process.
  371. ;
  372. ; Also: although the drive and user # is in ascii (for convenience
  373. ;    in setting up the table), be sure to use caps for the
  374. ;    drive designation.  No error checking is done on the values.
  375. ;
  376. ; Note: all entries in the following table call either Drive A or
  377. ;    Drive B to avoid hangs on a two drive system.  You may call
  378. ;    any and all drives that are actually on-line at one time.
  379. ;
  380. table:    db    'SYS',1,'* * System Disk * *',0,'0A'
  381. ;
  382. è    db    'ASM',1,'Assembler System Area',0,'2A'
  383.     db    'ASM_FILE',1,'Assembler Temporary File Area',0,'2B'
  384. ;
  385.     db    'C',1,'"C" System Area',0,'7A'
  386.     db    'C_FILE',1,'"C" Temporary File Area',0,'7B'
  387.     db    'CHRIS',1,'User Area for Chris',0,'8A'
  388. ;
  389.     db    'DBASE',1,'dBase ][ System Area',0,'4A'
  390.     db    'D_CMD',1,'dBASE ][ Command File Area',0,'4B'
  391.     db    'DOC',1,'Documentation Files Area',0,'0B'
  392. ;
  393.     db    'FLOP1',1,'Floppy Drive A:',0,'0A'
  394.     db    'FLOP2',1,'Floppy Drive B:',0,'0B'
  395.     db    'FORTRAN',1,'ForTran System Area',0,'6A'
  396. ;
  397.     db    'JEAN',1,'Work Space for Jean',0,'9A'
  398.     db    'LISP',1,'LISP Program Development Area',0,'8A'
  399. ;
  400.     db    'MP',1,'MultiPlan System Area',0,'3A'
  401.     db     'MODEM',1,'Telephone Communications Area',0,'2A'
  402.     db    'M_FILE',1,'Temporary Modem File Area',0,'2B'
  403. ;
  404.     db    'QC',1,'Quickcode System Area',0,'5A'
  405. ;
  406.     db    'SC',1,'SuperCalc System Area',0,'3A'
  407. ;
  408.     db    'WP',1,'Word Processing System Area',0,'1A'
  409.     db    'WS-HOME',1,'WordStar Files - Home',0,'1B'
  410.     db    'WS-WORK',1,'WordStar Files - Office',0,'1A'
  411.     db    'WS-$$',1,'WordStar Files - Business',0,'1B'
  412. ;
  413.     db    0        ;<<== end of table
  414. ;
  415. ; -----< end of SECTIONS table>-----
  416. ;
  417.     end    pbase        ;that's all.
  418.