home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol096 / muchtext.a86 < prev    next >
Text File  |  1984-04-29  |  4KB  |  156 lines

  1. ;        MUCHTEXT.A86 Version 1.0 as of March 29, 1981
  2. ;                By: Kelly Smith, CP/M-Net
  3. ;      I  spend a fair amount of time using Wordstar for doing 
  4. ; software  documentation,   letter  writing,  and  especially 
  5. ; magazine  articles that pay by the page...it's nice to  know 
  6. ; at times just how much stuff I have "cranked-out" during the 
  7. ; course of one of my long-winded Wordstar sessions...
  8. ;      So,  just  How-MUCHTEXT did I type?  Well,  I put  this 
  9. ; together  to tell me.  Works accurately on text  files,  but 
  10. ; don't  use  it  on  non-ASCII  files  to  get  a   character 
  11. ; count, 'cause it will be wrong.
  12. ;      MUCHTEXT  doesn't  care how the text was  prepared,  as 
  13. ; long  as  a  line  has a ASCII line  feed  delimeter  in  it 
  14. ; (indicating the end of a line). This seems to work very well 
  15. ; in  all cases that I have tried...Here is an example of  how 
  16. ; to use it:
  17. ; A>muchtext muchtext.asm<cr>
  18. ; Contains      150 lines of text
  19. ; A total,     3955 characters
  20. ; A0>
  21. ;      If you have any bright ideas for improvements,  I would 
  22. ; appreciate  it if you would MODEM it to the CP/M-Net  System 
  23. ; as "MUCHTEXT.NEW", to share with others.
  24. ;                                        Best regards, 
  25. ;                                        Kelly Smith, CP/M-Net
  26. ;
  27. ;
  28. ;
  29. bdos    EQU    05h            ; CP/M BDOS entry address
  30. fcb    EQU    5ch            ; CP/M FCB address
  31. ;
  32. wbfc    EQU    0            ; warm boot function
  33. psfc    EQU    9            ; print string
  34. offc    EQU    15            ; open file
  35. sdma    EQU    26            ; set dma address
  36. rrfc    EQU    20            ; read record
  37. ;
  38. lf    EQU    0ah            ; ASCII line feed
  39. cr    EQU    0dh            ; ASCII carriage return
  40. ;
  41. M    EQU    Byte Ptr 0[BX]
  42. ;
  43.     ORG    0100h
  44. ;
  45.     MOV    DX,fcb
  46.     MOV    CL,offc            ; open file name specified in the fcb
  47.     INT    224
  48.     INC    AL
  49.     JNZ    openok
  50.     CALL    prnexit
  51.     DB    cr,lf,lf,'+++ Can''t open file! +++$'
  52. openok:    PUSH    BX
  53.     MOV    BX,Word Ptr dmabuf    ; point to dma buffer
  54.     MOV    AL,Byte Ptr extcnt    ; get extent count
  55.     OR    AL,AL
  56.     JNS    nextrec
  57.     MOV    BX,Word Ptr dmabuf
  58.     XCHG    BX,DX
  59.     MOV    CL,sdma            ; set dma address for file
  60.     INT    224
  61.     MOV    DX,fcb
  62. readin:    MOV    CL,rrfc            ; read record
  63.     INT    224
  64.     OR    AL,AL
  65.     JNZ    ateof            ; at the end-of-file yet?
  66.     MOV    BX,Word Ptr dmabuf    ; get next record for next extent
  67.     XOR    AL,AL            ; set up next extent
  68.     JMPS    nextrec
  69. ;
  70. nextrec:INC    AL            ; update extent count
  71.     MOV    Byte Ptr extcnt,AL
  72.     DEC    AL
  73.     ADD    AL,BL            ; you put your right foot in...
  74.     MOV    BL,AL
  75.     MOV    AL,BH
  76.     ADC    AL,0
  77.     MOV    BH,AL            ; you put your right foot out...
  78.     MOV    AL,M            ; get character...and shake it all about
  79.     POP    BX
  80.     CMP    AL,'Z'-40h        ; end of file?
  81.     JZ    ateof            ; if so, finish up...
  82.     LAHF                ; save character
  83.     XCHG    AL,AH
  84.     PUSH    AX
  85.     MOV    BX,(Offset chars)    ; do range check on digits count
  86. nxtpos:    MOV    AL,M
  87.     CMP    AL,' '            ; this position occupied yet?
  88.     JNZ    nocary
  89. cary:    MOV    AL,'0'            ; make an ascii zero character
  90. nocary:    INC    AL            ; +1 to digit position
  91.     MOV    M,AL
  92.     CMP    AL,':'            ; digit >9?
  93.     JNZ    less9            ; if so, check if line feed
  94.     MOV    M,'0'            ; zero this digit
  95.     DEC    BX
  96.     JMPS    nxtpos            ; try the next position
  97. less9:    POP    AX            ; get character
  98.     XCHG    AL,AH
  99.     CMP    AL,lf            ; I walk the line...you know your mine
  100.     JZ    L_1    
  101.     JMP    openok
  102. L_1:
  103.     MOV    BX,(Offset lines)    ; point to number of lines
  104. nxtpos1:MOV    AL,M
  105.     CMP    AL,' '            ; this position occupied yet?
  106.     JNZ    nocary1
  107.     MOV    AL,'0'            ; make an ascii zero character
  108. nocary1:INC    AL
  109.     MOV    M,AL
  110.     CMP    AL,':'            ; digit >9?
  111.     JZ    L_2    
  112.     JMP    openok
  113. L_2:
  114.     MOV    M,'0'            ; zero this digit
  115.     DEC    BX
  116.     JMPS    nxtpos1            ; try the next position
  117. ;
  118. ateof:    CALL    prnexit            ; finally at the "end-of-file"...give info, and exit
  119.     DB    cr,lf
  120.     DB    'Contains '
  121.     DB    '       '
  122. lines    DB    '0 lines of text'
  123.     DB    cr,lf
  124.     DB    'A total, '
  125.     DB    '       '
  126. chars    DB    '0 characters'
  127.     DB    cr,lf,'$'
  128. ;
  129. exit:    MOV    CL,0            ; get back Loretta...
  130.     INT    224
  131. ;
  132. prnexit:POP    DX            ; get message string off the stack from "call"
  133.     MOV    CL,psfc            ; print string
  134.     INT    224
  135.     JMPS    exit            ; exit...gracefully
  136. L_3    EQU    $
  137.     DSEG
  138.     ORG    Offset L_3
  139. ;
  140. dmabuf    DW    0080h            ; default dma disk buffer pointer
  141. ;
  142. extcnt    DB    080h            ; extent count
  143. ;
  144.     END
  145.