home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / cpm / utils / f / freebase.ark / ENTER.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-02-05  |  4.8 KB  |  179 lines

  1. ;************************************************************
  2. ;            ENTER.ASM
  3. ;
  4. ;
  5. ;          A program to store text in a file.
  6. ;       Enter one and a half lines of text, 
  7. ;          terminated by a CR, per record.  
  8. ;       to exit, type two returns.  
  9. ;
  10. ; This file is based heavily on a
  11. ;  program taken from THE SOLE OF CP/M
  12. ;  by David Brown, Studio City, CA
  13. ;
  14. ;    TERMINAL SPECIFIC STUFF FOR FREEDOM 50
  15. ;
  16. ;
  17. ;
  18. ;
  19. ;
  20.     openf    equ    0fh    ;open file
  21.     makef    equ    16h    ;read string
  22.     reads    equ    0ah    ;write sequential record
  23.     writer    equ    15h    ;writes sequential record
  24.         readr   equ     14h     ;read sequential record
  25.     prints    equ    9h    ;print string
  26.     closef    equ    10h    ;close file
  27.     conout    equ    2h    ;console out
  28.     bdos    equ    5h    ;operating system entry
  29.     fcb    equ    5ch    ;file control block
  30.     dma    equ    80h    ;dma buffer
  31.     del    equ    0ffh    ;delete character
  32.     lf    equ    0ah    ;linefeed
  33.     cr    equ    0dh    ;carriage return
  34. ;
  35. ;
  36.         org    100h
  37. ;
  38. ;try to open file (name must already be in fcb)
  39.     mvi    c,openf    ;open file
  40.     lxi    d,fcb
  41.     call    bdos
  42.     inr    a    ;if a was ff, now it's 0
  43.     jnz    alex    ; not 0, so file exists
  44. ;
  45. ;file does not already exist, so we'll create it
  46.     mvi    c,makef
  47.     lxi    d,fcb
  48.     call     bdos
  49. ;
  50. ;fill the dma buffer with delete marks
  51. newrc    lxi    h,dma    ;put dma address in hl
  52.     mvi    b,128d    ;put count in b
  53. loop    mvi    m,del    ;store delete in memory
  54. ;
  55. ;            
  56.     inx    h    ;increment hl pointer
  57.     dcr    b    ;decrement count
  58.     jnz    loop
  59. ;
  60. ;print a linefeed
  61.     mvi    c,conout
  62.     mvi    e,lf
  63.     call    bdos
  64. ;
  65. ;read characters into buffer from keyboard
  66.     mvi    a,128d    ;set count to 128 characters
  67.     sta    dma-2    ; (string buffer starts 2
  68.     mvi    c,reads    ;  bytes before dma
  69.     lxi    d,dma-2    ;  buffer, to leave room for
  70.     call    bdos    ;  max-count and count)  
  71. ;
  72. ;find out if buffer is empty-if so, exit
  73.     lda    dma-1    ;get number of char input
  74.     ora    a    ;is it 0?
  75.     jz    finito    ; yes
  76.  
  77. ;
  78. ;insert cr and lf in buffer following text
  79.     mov    e,a    ;character count in de
  80.     mvi    d,0    ;
  81.     lxi    h,dma    ;dma address in hl
  82.     dad    d    ;add count to addr, put in hl
  83.     mvi    m,cr    ;store carriage return
  84.     inx    h    ;increment pointer
  85.     mvi    m,lf    ;store linefeed
  86.  
  87. ;
  88. ;write record to disk
  89.     mvi    c,writer    ;write it
  90.     lxi    d,fcb
  91.     call    bdos
  92.         jmp     necch   ;go to necch; clear scrn and signon w/banner*
  93. ;
  94. ;close filel before exiting
  95. finito    mvi    c,closef
  96.     lxi    d,fcb
  97.     call    bdos
  98.     jmp     clearit  ;goto clear screen before ret
  99. ;
  100. ;file already exits, so read till EOF
  101. ;
  102. ;
  103. alex    mvi    c,prints ;print message
  104.     lxi    d,almess
  105.     call    bdos
  106. read2    mvi    c,readr    ;read record
  107.     lxi     d,fcb
  108.     call    bdos
  109. è    ora    a    ;end-O-file (a not 0) ?
  110.     jz    read2    ;no, so read next record
  111.     jmp    newrc     ;yes, so write the bastard!
  112. ;
  113. ;
  114. ;necch 
  115. necch   mvi     c,closef 
  116.         lxi     d,fcb
  117.         call    bdos
  118.         mvi     c,prints ; prints message
  119.         lxi     d,almess
  120.         call    bdos
  121.         jmp     read2
  122.  
  123. ;
  124. ;clearit 
  125. clearit mvi     c,prints  ;prints message
  126.         lxi     d,clearsn
  127.         call    bdos
  128.         ret               ;drop back to cpm
  129.  
  130. ;
  131. ;
  132. almess    db     27,42    ;blow away screen
  133.     db    27,119  ; set up for setting intensity per char
  134.         db      27,93,56 ;row 1, col 25 -- to center, I hope
  135.         db      27,71,52 ; set intensity to full blast
  136.     db    'F r e e  B a s e  II'
  137.         db      27,71,48 ; shut off intensity
  138.     db    cr,lf
  139.         db      cr,lf
  140.         db      27,93,56 ;same as above -- to center
  141.         db      ' DATA ENTRY PROGRAM'    
  142.         db      cr,lf,cr,lf
  143.         db      cr,lf
  144.         db      27,93,56 ;row 1, col 25, too
  145.         db      cr,lf
  146.     db    'Type whatever you like, in any order you wish -- '
  147.     db      'up to a line '
  148.     db    cr,lf,'and a half -- or 127 characters.'
  149.         db      cr,lf
  150.         db      cr,lf
  151.         db      cr,lf
  152.     db    27,91,41       ; 8th line, col 1
  153.         db      27,113
  154.         db      '|__________________________________________________________'
  155.         db      '_____________________'
  156.         db      cr,lf
  157.         db      '--------------------------------------------->|'
  158.         db      cr,lf
  159.         db      27,114
  160.         db      7
  161.         db      '                            End 2nd line Here ^'
  162.         db      cr,lf
  163.         db      cr,lf
  164. è        db      '              ============================================='
  165.         db      cr,lf,cr,lf
  166.         db      '                 Press  {RETURN} After Record is Entered'
  167.         db      cr,lf
  168.         db      '                      Press  {Return) Twice to Exit'
  169.         db      cr,lf,cr,lf
  170.         db      '                    To Search for Information, Enter: '
  171.         db      cr,lf  
  172.         db      '                         A>SEARCH  [D:] File.Type'
  173.         db      cr,lf    
  174.         db      '              ============================================='
  175.     db    27,91,39     ;return to scene of crime...
  176.         db      cr,lf,'$'
  177. ;
  178. clearsn db      27,42,'$'
  179. ;
  180. end
  181.