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 / CPM / CPM3 / NULL.LBR / NULL.AZM / NULL.ASM
Assembly Source File  |  2000-06-30  |  4KB  |  228 lines

  1. ;NULL v1.0  - CP/M Plus Utility - For writing a 0 byte file to disk
  2. ;
  3. ;        COPYRIGHTED  1984  BY GUY GAMBLE
  4. ;
  5. ; This utility takes the place of the A>SAVE 0 filename.ext of CPM 2.2
  6. ; and before.  The main reason I wrote this was to make it easy to write
  7. ; a directory entry of type  -.123  so the popular MCAT program can be
  8. ; used with C/PM Plus operating system.  The program is self explanatory
  9. ; so I did not write a DOC file.
  10. ;
  11. ; The only thing you might need to know is that drive B: is the default
  12. ; drive that the program writes to.  So you don't need to specify any
  13. ; drive when you name the file.
  14. ;
  15. ; This program is donated to Public Domain and I hope people will im-
  16. ; prove on it.  It is not intended for commercial distribution.  If you
  17. ; make modifications please update and resubmit to the Public Domain
  18. ; either here or any other RCPM BBS.
  19. ;                    - Guy Gamble
  20. ;
  21. ;=======================================================================
  22. ;
  23. ; System Equates under CP/M Plus
  24. ;
  25. BASE:    EQU    0
  26. FCB:    EQU    BASE+5CH
  27. BDOS:    EQU    BASE+5
  28. PRINT:    EQU    9
  29. CONIN:    EQU    1
  30. CONOUT:    EQU    2
  31. RESETD:    EQU    13        ;Disk system reset both drives
  32. SDSKR:    EQU    37        ;Single disk reset
  33. SELDK:    EQU    14
  34. PFCB:    EQU    152        ;CPM Plus only  PARSE FCB
  35. RCONBF:    EQU    10
  36. MAKEF:    EQU    22
  37. OPEN:    EQU    15
  38. CLOSE:    EQU    16
  39. ;
  40. ;
  41. ; EQU for ASCII characters
  42. ;
  43. CR:    EQU    0DH
  44. LF:    EQU    0AH
  45. CLS:    EQU    1AH        ;Clear screen
  46. ;
  47. ;
  48. ;
  49. ORG    BASE+100H
  50. ;
  51. ;
  52. ;            Sign on messege
  53. ;
  54.     CALL    ILPRT
  55.     DB    CLS,LF,'  NULL FILE UTILITY v1.0 - for  CPM PLUS - 03/19/84'
  56.     DB    CR,LF,LF
  57.     DB    '  This writes a NULL file to drive B:',CR,LF,LF,0
  58. ;
  59. START:    LDA    BUFLEN        ;Maximum input buffer length (12 char)
  60.     STA    INBUF        ;initialize 0 byte of the input buffer
  61. ;                ;for BDOS function 10
  62. ;
  63. ;
  64.     LXI    SP,STACK    ;local stack
  65.     XRA    A
  66.     CALL    ILPRT
  67.     DB    '  Type Q to QUIT  or',CR,LF,LF
  68.     DB    '  Press RETURN to continue ',0
  69.     CALL    CRTIN
  70.     CPI    'Q'
  71.     JZ    QUIT
  72.     CPI    CR
  73.     JZ    MSG
  74.     CALL    ILPRT
  75.     DB    CLS,LF,LF,'  TRY AGAIN !!',CR,LF,LF,0
  76.     JMP    START
  77. ;
  78. ;
  79. ;
  80. MSG:    CALL    ILPRT
  81.     DB    CLS,LF,LF,'  INSERT DISK in drive B:',CR,LF,LF
  82.     DB    '  ENTER   FILENAME.EXT',CR,LF,LF
  83.     DB    '         :',0
  84.     CALL    INPUT
  85.     CALL    MOVFN        ;move name from inbuf to FCB
  86. ;                ;BDOS function 152 under CPM Plus only
  87.     CALL    RESDSK
  88.     CALL    OFILE
  89.     INR    A
  90.     JNZ    ERR1
  91.     CALL    MFILE
  92.     INR    A
  93.     JZ    ERR2
  94.     CALL    CFILE
  95.     CALL    ILPRT
  96.     DB    CLS,LF,LF,0
  97.     JMP    INIT
  98. ;
  99. ;
  100. ILPRT:    XTHL            ;inline print routine
  101. ;
  102. ;
  103. ILPLP:    MOV    A,M
  104.     PUSH    H
  105.     CALL    CRTOUT
  106.     POP    H
  107.     INX    H
  108.     MOV    A,M
  109.     ORA    A
  110.     JNZ    ILPLP
  111.     INX    H
  112.     XTHL
  113.     RET
  114. ;
  115. ;
  116. CRTOUT:    PUSH    PSW
  117.     MVI    C,CONOUT
  118.     MOV    E,A
  119.     CALL    BDOS
  120.     POP    PSW
  121.     RET
  122. ;
  123. ;
  124. CRTIN:    MVI    C,CONIN
  125.     CALL    BDOS
  126.     ANI    07FH
  127.     CPI    ' '
  128.     RZ
  129.     CPI    'C'-40H
  130.     JZ    QUIT
  131.     CPI    ' '
  132.     RC
  133.     ANI    05FH
  134.     RET
  135. ;
  136. ;
  137. ;
  138. INPUT:    MVI     C,RCONBF    ;BDOS function 10
  139.     LXI    D,INBUF        ;input buffer address
  140.     CALL    BDOS
  141.     CALL    CRLF
  142.     RET
  143. ;
  144. ;
  145. MOVFN:    MVI    C,PFCB        ;move filename.ext from input
  146. ;                ;buffer to FCB. BDOS 152 CPM Plus only
  147.     LXI    D,PFILE
  148.     CALL    BDOS
  149.     RET
  150. ;
  151. ;
  152. RESDSK:    MVI    C,SDSKR        ;reset drive B: only
  153.     LXI    D,0002
  154.     CALL    BDOS
  155. ;
  156.     MVI    C,SELDK        ;select drive B:
  157.     MVI    E,01
  158.     CALL    BDOS
  159.     RET
  160. ;
  161. ;
  162. OFILE:    MVI    C,OPEN        ;check to see if file exists
  163.     LXI    D,FCB
  164.     CALL    BDOS
  165.     RET
  166. ;
  167. ;
  168. MFILE:    MVI    C,MAKEF        ;write file to disk
  169.     LXI    D,FCB
  170.     CALL    BDOS
  171.     RET
  172. ;
  173. ;
  174. CFILE:    MVI    C,CLOSE
  175.     LXI    D,FCB
  176.     CALL    BDOS
  177.     RET
  178. ;
  179. ;
  180. INIT:    LXI    H,INBUF        ;initialization of input buffer
  181.     LXI    D,INBUF+1
  182.     LXI    B,0026H
  183.     MVI    M,0        ;fill with 0's
  184.     DB    0EDH,0B0H    ;Z80 LDIR command
  185.     JMP    START        ;start over again
  186. ;
  187. ;
  188. ERR1:    CALL    CFILE
  189.     CALL    ILPRT
  190.     DB    CLS,LF,LF,'  +++ FILE ALREADY EXISTS +++',CR,LF,LF,0
  191.     JMP    INIT
  192. ;
  193. ;
  194. ERR2:    CALL    ILPRT
  195.     DB    CLS,LF,LF,'  +++ NO DIRECTORY SPACE +++',CR,LF,LF,0
  196.     JMP    INIT
  197. ;
  198. ;
  199. QUIT:    CALL    CRLF
  200.     MVI    C,RESETD    ;reset both drives before returning
  201. ;                ;to CPM
  202.     CALL    BDOS
  203.     JMP    BASE
  204. ;
  205. ;
  206. CRLF:    CALL    ILPRT
  207.     DB    CR,LF,0
  208.     RET
  209. ;
  210. ;
  211.     DS    80        ;local stack
  212. STACK:    DB    0,0,0
  213. ;
  214. ;
  215. PFILE:    DW    INBUF+2        ;BDOS function 152
  216.     DW    FCB        ;move filename.ext from inbuf+2
  217.     DB    0,0,0        ;to FCB address
  218. ;
  219. ;
  220. BUFLEN:    DB    0CH,0,0        ;maximum number of char allowed
  221. ;                ;to be input -filename.ext
  222. ;                ;currently set for 12 chars
  223. INBUF:    DB    0,0
  224.     DS    26H
  225. ;
  226. ;
  227.     END
  228.