home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ZSYS / SIMTEL20 / ZCPR3 / SHSET.MAC < prev    next >
Text File  |  2000-06-30  |  4KB  |  207 lines

  1. ;  PROGRAM:  SHSET
  2. ;  VERSION:  1.0
  3. ;  DATE:  19 July 84
  4. ;  AUTHOR:  Richard Conn
  5. ;  PREVIOUS VERSIONS:  None
  6. ;
  7. z3env    equ    0f400h
  8. VERS    EQU    10        ;version number
  9.  
  10. ; SHSET is copyright (c) 1984 by Richard Conn
  11. ; All Rights Reserved
  12. ; SHSET may be used freely by the ZCPR3 Community
  13.  
  14. ;
  15. ;    SHSET is used to establish a command line as a shell.  It pushes
  16. ; the command line (including semicolons) which follow the verb SHSET onto
  17. ; the shell stack if it fits.
  18. ;
  19. ; Syntax:
  20. ;    SHSET cmd1;cmd2;...
  21. ;
  22. ; The sequence of commands "cmd1;cmd2;..." becomes the shell.
  23. ;
  24.  
  25. ;
  26. ;  SYSLIB, Z3LIB, and VLIB References
  27. ;
  28.     ext    z3init
  29.     ext    shpush,getcl1,getcl2,putshm,getsh,getsh2
  30.     ext    eprint,phlfdc
  31.     ext    codend
  32.  
  33. ;
  34. ;  Basic Definitions
  35. ;
  36. TRUE     EQU    0FFH        ;define true and..
  37. FALSE     EQU    0           ;..false.
  38.  
  39. ;
  40. ; System Addresses
  41. ;
  42. OS$BASE EQU    000H        ;system base..
  43. BDOS    EQU    OS$BASE+05H
  44. FCB    EQU    OS$BASE+5CH
  45. FCB2    EQU    OS$BASE+6CH
  46. TBUFF    EQU    OS$BASE+80H
  47. TPA    EQU    OS$BASE+100H
  48.  
  49. ;
  50. ;  ASCII Chars
  51. ;
  52. LF    EQU    0AH        ;..linefeed..
  53. CR    EQU    0DH        ;..carriage return..
  54.  
  55. ;
  56. ; Environment Definition
  57. ;
  58.     if    z3env ne 0
  59. ;
  60. ; External ZCPR3 Environment Descriptor
  61. ;
  62.     jmp    start
  63.     db    'Z3ENV'    ;This is a ZCPR3 Utility
  64.     db    1    ;External Environment Descriptor
  65. z3eadr:
  66.     dw    z3env
  67. start:
  68.     lhld    z3eadr    ;pt to ZCPR3 environment
  69. ;
  70.     else
  71. ;
  72. ; Internal ZCPR3 Environment Descriptor
  73. ;
  74.     MACLIB    Z3BASE.LIB
  75.     MACLIB    SYSENV.LIB
  76. z3eadr:
  77.     jmp    start
  78.     SYSENV
  79. start:
  80.     lxi    h,z3eadr    ;pt to ZCPR3 environment
  81.     endif
  82.  
  83. ;
  84. ; Mainline
  85. ;
  86.     call    z3init        ;initialize the ZCPR3 Env
  87.  
  88. ;
  89. ; Print Prompt
  90. ;
  91.     call    eprint
  92.     db    'SHSET, Version '
  93.     db    (VERS/10)+'0','.',(VERS MOD 10)+'0'
  94.     db    0
  95.     lda    fcb+1        ;check for help request
  96.     cpi    '/'        ;help?
  97.     jz    help
  98.     cpi    ' '
  99.     jnz    shinit
  100. ;
  101. ; Print Help Message
  102. ;
  103. help:
  104.     call    eprint
  105.     db    cr,lf,' Syntax:  SHSET cmd1;cmd2;...'
  106.     db    cr,lf,' SHSET defines the command sequence to be a shell'
  107.     db    0
  108.     ret
  109. ;
  110. ; Initialize Shell
  111. ;
  112. shinit:
  113.     call    shtest1        ;there must be a shell stack
  114.     call    shtest2        ;there must be a command line buffer
  115. ;
  116. ; HL now points to the command line buffer
  117. ;
  118.     call    codend        ;pt to free area
  119.     xchg            ;... in DE
  120.     lxi    h,tbuff+1    ;pt to option input
  121.     mov    a,m        ;check for no input
  122.     ora    a        ;none if zero
  123.     jz    checkcl
  124.     inx    h        ;pt to first good char
  125.     call    copystr        ;copy string
  126. checkcl:
  127.     call    getcl2        ;get address of command line
  128.     jz    setsh        ;set shell command
  129.     call    copystr        ;copy string
  130. setsh:
  131.     call    codend        ;pt to string
  132.     call    shpush        ;push onto shell stack
  133.     jnz    sherr        ;error?
  134. ;
  135. ;  Set Shell Messages
  136. ;
  137.     mvi    a,0        ;Zero Message 0
  138.     mvi    b,0
  139.     call    putshm
  140. ;
  141.     mvi    a,0        ;Zero Message 1
  142.     mvi    b,1
  143.     call    putshm
  144. ;
  145.     call    eprint
  146.     db    ' Shell Installed',0
  147. ;
  148. exit:
  149.     call    getcl2        ;terminate following command
  150.     mvi    m,0        ;set ending 0
  151.     ret
  152. ;
  153. ;  Error in Shell Stack Installation
  154. ;
  155. sherr:
  156.     cpi    2        ;shell stack full
  157.     jnz    sherr1
  158.     call    eprint
  159.     db    ' Shell Stack Full',0
  160.     jmp    exit
  161. sherr1:
  162.     call    eprint
  163.     db    ' Shell Entry too Large -- Limit is ',0
  164.     call    getsh2        ;get limit in DE
  165.     xchg
  166.     call    phlfdc        ;print as floating decimal
  167.     call    eprint
  168.     db    ' Characters',0
  169.     jmp    exit
  170.  
  171. ;
  172. ; Check for Presence of Shell Stack
  173. ;
  174. shtest1:
  175.     call    getsh        ;get shell stack data
  176.     rnz
  177.     pop    psw        ;clear stack
  178.     call    eprint
  179.     db    ' No Shell Stack',0
  180.     ret
  181.  
  182. ;
  183. ; Check for Command Line
  184. ;
  185. shtest2:
  186.     call    getcl1        ;get command line data
  187.     rnz
  188.     pop    psw        ;clear stack
  189.     call    eprint
  190.     db    ' No Command Line',0
  191.     ret
  192.  
  193. ;
  194. ; Copy string from HL to DE
  195. ;   Store ending 0 and leave pointer in DE to it
  196. ;
  197. copystr:
  198.     mov    a,m        ;get char
  199.     stax    d        ;store it
  200.     ora    a        ;done?
  201.     rz
  202.     inx    h        ;pt to next
  203.     inx    d
  204.     jmp    copystr
  205.  
  206.     end
  207.