home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / f / freebase.lbr / ENTER.AZM / ENTER.ASM
Encoding:
Assembly Source File  |  1993-10-26  |  4.5 KB  |  188 lines

  1. ;****************************************************
  2. ;*                ENTER2.ASM                        *
  3. ;*  A program to store 127 character text lines     *
  4. ;*  in a sequential file.  Text is entered using    *
  5. ;*  standard editing keys, entry terminated by a    *
  6. ;*  CR.  CR with no text entry ends program.        *
  7. ;*                                                  *
  8. ;*  Modified from ENTER.ASM written by David        *
  9. ;*  Brown      which was based on a program from    *
  10. ;*  THE SOLE OF CP/M.  Modified so it would work    *
  11. ;*  as intended by Noel Nyman.  Released to the     *
  12. ;*  public domain as part of FREBASE2.              *
  13. ;****************************************************
  14. ;
  15. ;  TERMINAL SPECIFIC COMMANDS FOR ADM31 (Commodore C-128)
  16. ;
  17.     openf    equ    15    ;open file
  18.     makef    equ    22    ;make file
  19.     reads    equ    10    ;read console buffer
  20.     writer    equ    21    ;write sequential record
  21.     readr    equ     20    ;read sequential record
  22.     prints    equ     9    ;print string
  23.      closef    equ    16    ;close file
  24.     conout    equ    02    ;console out
  25.     bdos    equ    05    ;operating system entry
  26.     fcb    equ    5ch    ;file control block
  27.     dma    equ    80h    ;dma buffer
  28. ;
  29.     space    equ    32    ;space character
  30.     lf    equ    10    ;line feed
  31.     cr    equ    13    ;carriage return
  32.         null    equ    00
  33. ;
  34. ;screen format codes
  35. ;
  36.     esc    equ    27    ;escape
  37.     eqls    equ    61    ;ascii for '='
  38.     base    equ    32    ;base for all row/col references
  39.     rvs    equ    71    ;reverse code
  40.     on    equ    52    ;ascii '4' turns reverse on
  41.     off    equ    48    ;ascii '0' turns reverse off
  42.     clrsc    equ    42    ;ascii '*' clears screen
  43. ;
  44.         org    100h    ;start of TPA
  45. ;
  46. ;open file named in fcb
  47. ;
  48.     mvi    c,openf        ;open file
  49.     lxi    d,fcb
  50.     call    bdos    
  51.     inr    a        ;change 255 to zero    
  52.     jnz    start        ;file exists
  53. ;
  54. ;file does not exist, try to create it
  55. ;
  56.     mvi    c,makef
  57.     lxi    d,fcb
  58.     call    bdos
  59.     inr    a        ;change 255 to zero
  60.     jnz    start        ;file created
  61. ;
  62. ;if we get here, disk directory is full
  63. ;
  64.     mvi    c,prints    
  65.     lxi    d,dirfull    ;print 'directory full' message
  66.     call     bdos    
  67.     ret            ;exit to CP/M
  68.  
  69. ;display main screen
  70. ;
  71. start:    
  72.     mvi    c,prints
  73.     lxi    d,mainscr
  74.     call      bdos
  75. ;
  76. ;read to end of file
  77. ;
  78. readend:
  79.     mvi    c,readr        ;read record
  80.     lxi    d,fcb
  81.     call    bdos
  82.     ora    a        ;end of file?
  83.     jz    readend        ;no, read another record
  84. ;
  85. ;print text boundary prompt
  86. ;
  87.     mvi    c,prints
  88.     lxi    d,prompt
  89.     call    bdos
  90. ;
  91. ;initialize buffer, fill with spaces, add '0' end-of-record marker
  92. ;
  93.     lxi    h,dma        ;dma address in hl
  94.     mvi    b,127        ;buffer size
  95. loop:
  96.     mvi    m,space        ;store space character in dma
  97.     inx    h        ;127 times
  98.     dcr    b
  99.     jnz     loop
  100.     mvi    m,null        ;add '0' at end
  101. ;
  102. ;read characters into buffer from keyboard
  103. ;
  104.     mvi    a,127        ;dma buffer size
  105.     sta    dma-2        ;max count
  106.     mvi    c,reads        ;read keyboard
  107.     lxi    d,dma-2
  108.     call    bdos
  109. ;
  110. ;fall through to here after carriage return
  111. ;
  112.     lda    dma-1        ;number of characters in buffer
  113.     ora     a        ;no characters?
  114.     jz    exit        ;yes, exit program
  115. ;
  116. ;write record to disk
  117. ;
  118.     mvi    c,writer
  119.     lxi    d,fcb
  120.     call     bdos
  121. ;
  122. ;close file
  123. ;
  124.     mvi    c,closef
  125.     lxi    d,fcb
  126.     call    bdos
  127.     jmp    readend        ;get another entry
  128. ;
  129. ;end program
  130. ;
  131. exit:
  132.      mvi    c,prints
  133.     lxi     d,clear        ;clear screen
  134.     call    bdos
  135.     mvi    c,closef    ;close file
  136.     lxi    d,fcb
  137.     call     bdos
  138.     ret            ;back to CP/M
  139. ;
  140. dirfull:
  141.     db    'Directory Full'
  142.     db    cr,lf,'$'
  143. ;
  144. ;main screen
  145. ;
  146. mainscr:
  147.     db    esc,clrsc            ;clear screen
  148.     db    esc,eqls,base,base+23        ;row 0, col 22
  149.     db    esc,rvs,on            ;reverse on
  150.     db    ' F r e e  B a s e  III '
  151.     db    esc,rvs,off            ;reverse off
  152.     db    esc,eqls,base+2,base+24        ;row 2, col 23
  153.     db    ' DATA ENTRY PROGRAM'
  154.     db    cr,lf,cr,lf
  155.  
  156.     db    'Type whatever you like, 127 characters maximum'
  157.     db    cr,lf,cr,lf,cr,lf,cr,lf
  158.     db    cr,lf,cr,lf,cr,lf,cr,lf
  159.     db    '              =============================='
  160.     db    '==============='
  161.     db    cr,lf,cr,lf
  162.     db    '                  Press   RETURN  After Record is Entered'
  163.     db    cr,lf
  164.     db    '                       Press  RETURN  Alone to EXIT'
  165.     db    cr,lf,cr,lf
  166.     db    '                        To Search for Information, Enter: '
  167.     db    cr,lf
  168.     db    '                    A>SEARCH [D:] filename.type information'
  169.     db    cr,lf
  170.     db    '              ============================='
  171.     db    '===================='
  172.     db    '$'
  173. ;
  174. prompt:
  175.     db    esc,eqls,base+7,base        ;row 7, col 0
  176.     db    '[-----------------------------'
  177.  
  178.     db    '------------------------------------------------- '
  179.     db    '-------------------------------------------------]'
  180.     db    cr,lf
  181.     db    '                              End 2nd Line Here ^'
  182.     db    esc,eqls,base+6,base+1        ;row 6, col 1
  183.     db     cr,lf,'[$'
  184. ;
  185. clear:
  186.     db    esc,clrsc,'$'            ;clear screen
  187. ;
  188.