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 / SIMTEL / CPMUG / CPMUG078.ARK / _.ASM next >
Assembly Source File  |  1984-04-29  |  4KB  |  176 lines

  1. ;/.ASM by John M. Kodis
  2. ;CP/M U.G. contrubution November 1980
  3. ;
  4. ;The "slant" program reads a command line which
  5. ;may contain several program invocations.  A $$$.SUB
  6. ;file is built with these commands.  This file is
  7. ;then executed.
  8. ;
  9. ;For example, the command line:
  10. ;
  11. ;/ asm copy; load copy; dir copy*.*; type copy.prn
  12. ;
  13. ;will build a file containing commands to assemble
  14. ;and load the file named 'copy', search the directory
  15. ;for all copy programs, and type the COPY.PRN file.
  16. ;
  17. ;Based on "/.ASM", CPMUG 40.1.  This program was
  18. ;written because the abstract for volume 40 states
  19. ;that 40.1 works only under CP/M version 1.4,
  20. ;and that the source code cannot be provided.  This
  21. ;version overcomes both of these difficulties.
  22. ;    (Note: 40.1 "1.4 only" meant "not 1.3".
  23. ;     it does work with 2.2 <Ward C.>)
  24. ;
  25. ;PROCESSOR:    ASM
  26. ;DEPENDENCIES:    NONE
  27. ;NOTES:        Set "DUP" to true, to define a version
  28. ;        which will write "/.SUB" out to disk
  29. ;        to facilitate re-executing the same commands.
  30. ;        To re-execute them, REN $$$.SUB=/.SUB
  31. ;        then ^C.  Alternatively, PIP $$$.SUB=/.SUB
  32. ;
  33. ;        You might wish to name the version of this
  34. ;        program assembled with DUP true, as ".COM
  35. ;
  36. ;        (but this will "screw up" the Master CATalog
  37. ;         system which reauires its "-name.xxx" to be
  38. ;         the first file found)
  39. ;
  40. ;    A program for quickie, use once and throw away submits.
  41. ;
  42. ;    The command syntax is:
  43. ;
  44. ;    A>/ <command line>[[;<command line>] ... ] <cr>
  45. ;
  46. closef    equ    16
  47. delete    equ    19
  48. writef    equ    21
  49. makef    equ    22
  50. dmaf    equ    26
  51. ;
  52. boot    equ      0    ;for a warm start
  53. bdos    equ      5    ;cp/m entry point
  54. chcnt    equ    080h    ;character count
  55. cibuf    equ    081h    ;console input buffer
  56. tpa    equ    100h    ;transient program area
  57. ;
  58. dup    equ    0
  59. ;
  60.     org    tpa
  61. ;
  62. slant:    lxi    h,chcnt
  63.     mov    a,l
  64.     add    m
  65.     inr    a
  66.     mov    l,a
  67.     mvi    m,0    ;zero the byte after the end of the command line.
  68. ;
  69.     lxi    d,cibuf    ;de is the source pointer.
  70.     lxi    h,subbuf+1;hl is the destination pointer.
  71. ;
  72. nxtcmd:    ldax    d
  73.     cpi    ' '
  74.     jnz    xfer    ;skip over leading blanks.
  75.     inx    d
  76.     jmp    nxtcmd
  77. ;
  78. xfer:    ldax    d
  79.     ana    a    ;end of line?
  80.     jz    cmdend
  81.     cpi    ';'    ;end of command?
  82.     jz    cmdend
  83.     mov    m,a    ;if neither, xfer it to the output buffer,
  84.     inx    d
  85.     inx    h    ;bump both pointers,
  86.     jmp    xfer    ;and try again.
  87. ;
  88. cmdend:    mvi    m,0    ;zero the byte after the end of the line.
  89.     mov    a,l
  90.     dcr    a
  91.     ani    7fh    ;accumulator has character count.
  92.     mov    b,a    ;save it.
  93.     mov    a,l
  94.     ani    80h
  95.     mov    l,a    ;hl points to the character count byte.
  96.     mov    m,b
  97. ;
  98.     ldax    d
  99.     ana    a    ;if we've reached the end of the input line...
  100.     jz    fileit    ;let's "file it".
  101.     lxi    b,129
  102.     dad    b
  103.     inx    d    ;point to the next character in the input.
  104.     jmp    nxtcmd    ;loop back for the next command.
  105. ;
  106. fileit:    push    h    ;save address of last zone
  107.     if    dup
  108.     lxi    d,xfcb
  109.     mvi    c,delete
  110.     call    bdos
  111.     endif
  112.     lxi    d,fcb
  113.     mvi    c,delete
  114.     call    bdos    ;delete any existing command files.
  115. ;
  116.     if    dup
  117.     lxi    d,xfcb
  118.     mvi    c,makef
  119.     call    bdos
  120.     endif
  121.     lxi    d,fcb
  122.     mvi    c,makef
  123.     call    bdos    ;create the new command files.
  124. ;
  125.     pop    h
  126. wrloop:    push    h
  127.     xchg
  128.     mvi    c,dmaf
  129.     call    bdos
  130. ;
  131.     if    dup
  132.     lxi    d,xfcb
  133.     mvi    c,writef
  134.     call    bdos
  135.     endif
  136.     lxi    d,fcb
  137.     mvi    c,writef
  138.     call    bdos    ;write the new commands, one command per
  139.             ;disk sector, writing the last command first.
  140. ;
  141.     pop    h    ;get current dma address
  142.     lxi    d,-128
  143.     dad    d
  144.     lxi    d,subbuf
  145.     mov    a,l
  146.     sub    e
  147.     mov    a,h
  148.     sbb    d
  149.     jnc    wrloop
  150. ;
  151.     if    dup
  152.     lxi    d,xfcb
  153.     mvi    c,closef
  154.     call    bdos
  155.     endif
  156.     lxi    d,fcb
  157.     mvi    c,closef
  158.     call    bdos    ;close the files after writing the last sector.
  159. ;
  160.     rst    boot    ;back to cp/m via a warm start.
  161.             ;changing this to a "ret" will return
  162.             ;to CP/M without the warm start, and so
  163.             ;the command file will not be executed
  164.             ;until the next boot from this disk.
  165. ;
  166. fcb:    db    1, '$$$     SUB'
  167.     dw    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  168. xfcb:    db    1, '/       SUB'
  169.     dw    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  170. ;
  171.     org    ($+0ffh) and 0ff00h
  172. ;
  173. subbuf:    ds    0
  174. ;
  175.     end    slant
  176.