home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 223_02 / gets.mac < prev    next >
Text File  |  1989-02-23  |  3KB  |  108 lines

  1.  
  2. ;
  3. ;    gets(buff)
  4. ;
  5. ;
  6. CBDOS    EQU    5    ;/* bdos entry point */
  7. CPMARG    EQU    128    ;/* CP/M command line */
  8. MAXARG    EQU    32    ;/* Maximum number of input args */
  9. STDIN    EQU    0
  10. STDOUT    EQU    1
  11. STDERR    EQU    2
  12. STDLST    EQU    4
  13. CTRLZ    EQU    26    ;control z
  14. NULL    EQU    0    ;pointer to nothing
  15. FCBSIZE    EQU    36    ;size, in bytes, of an FCB
  16. NEXTP    EQU    0    ;offset    to next-character pointer in I/O structure
  17. UNUSED    EQU    2    ;offset    to unused-positions-count in I/O structure
  18. BUFFER    EQU    6    ;offset    to disk    sector buffer in I/O structure
  19. UNGOT    EQU    5    ;offset to char ungotten by ungetc()
  20. FLAG    EQU    33    ;file-type flag    byte (in unused    part of    FCB)
  21. FREEFLG    EQU    128    ;This I/O structure is available for the taking
  22. EOFFLG    EQU    2    ;The end of this file has been hit
  23. WRTFLG    EQU    1    ;This file open    for writing
  24. BUFSIZ    EQU    1024    ;how long the sector buffer is
  25. NBUFS    EQU    8    ;number    of I/O buffers
  26. TBUFF    EQU    128    ;default cpm buffer
  27. LF    EQU    10
  28. EOL    EQU    13    
  29. ;
  30. ; CP/M BDOS CALLS 
  31. ;
  32. CLOSE    EQU    16    ;close a file
  33. CPMSTR    EQU    9    ;print '$' delimited string on console
  34. CREATE    EQU    22    ;make a    file
  35. DMA    EQU    26    ;set DMA (I/O address)
  36. DELETE    EQU    19    ;delete    a file
  37. GETCH    EQU    1    ;read character    from console
  38. GETSTR    EQU    10    ;read string from console
  39. LSTOUT    EQU    5    ;write character to list device
  40. OPEN    EQU    15    ;open a    file
  41. PUTCH    EQU    2    ;write character to console
  42. QUERY    EQU    25    ;get logged-in drive id
  43. READ    EQU    20    ;read a    sector
  44. SELECT    EQU    14    ;log-in    a drive
  45. WRITE    EQU    21    ;write a sector
  46. ;
  47. ;    File i/o storage varibles found in ulink()
  48. ;
  49. EXTRN    ZZUNIT
  50. EXTRN    ZZIP
  51. EXTRN    ZZCHP
  52. EXTRN    ZZDP
  53. EXTRN    ZZFILE
  54. EXTRN    ZZMODE
  55. EXTRN    ZZCH
  56. EXTRN    ZZT
  57. EXTRN    ZZFN
  58. EXTRN    ZZNUBU
  59. EXTRN    ZZMXSC
  60. ;
  61. ;    Characteristics variable storage found in ulink()    
  62. ;
  63. EXTRN    ZZSVCH
  64. EXTRN    ZZDFLT
  65. EXTRN    ZZSTAK
  66. EXTRN    ZZMEM
  67. ;
  68. EXTRN    GETC
  69. ;
  70. GETS::
  71.     POP    B
  72.     POP    H
  73.     PUSH    H
  74.     PUSH    B
  75.     SHLD    ZZCHP
  76.     DCX    H            ; save = buff[-1]; save2 = buff[-2];
  77.     MOV    D,M            ; buff[-1] = 0;     buff[-2] = 79;
  78.     MVI    M,0
  79.     DCX    H
  80.     MOV    E,M
  81.     MVI    M,79                    ;6 May 80 rj
  82.     PUSH    H
  83.     PUSH    D
  84.     XCHG                ; cpm(GETSTR,buff-2);
  85.     MVI    C,GETSTR
  86.     CALL    CBDOS        ; (mod to cbdos(fas))
  87.     LHLD    ZZCHP            ; buff[buff[-1]] = 0; (9 Jun 80. Was cp)
  88.     DCX    H
  89.     MOV    E,M
  90.     INX    H
  91.     MVI    D,0
  92.     DAD    D
  93.     MVI    M,0
  94.     POP    D            ; buff[-1] = save; buff[-2] = save2;
  95.     POP    H
  96.     MOV    M,E
  97.     INX    H
  98.     MOV    M,D
  99.     INX    H
  100.     MVI    C,PUTCH            ; putchar('\n');
  101.     MVI    E,LF
  102.     CALL    CBDOS        ; (mod to cbdos(fas))
  103.     LHLD    ZZCHP            ; return(buff);
  104.     RET            ; }
  105.  
  106.     END
  107.  
  108.