home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / MAXONC3_6OF8.DMS / in.adf / LIBSRC.LHA / LIBSRC / stdinput.asm < prev    next >
Encoding:
Assembly Source File  |  1994-04-15  |  1.6 KB  |  98 lines

  1.  
  2.     ;* Maxon C++ Projekt:
  3.     ;* Library-Modul "stdinput"
  4.     ;* Jens Gelhar 15.11.91, 31.08.93
  5.  
  6.     xdef    _getc,getc__P06stream,_fgetc,fgetc__P06stream
  7.     xdef    _getchar,getchar_
  8.     xdef    __Readfile,__Readfile__NoBuf
  9.  
  10.     xref    __Readflag,_DOSBase,_std__in
  11.  
  12. Read    = -42
  13.  
  14. str_ungetch    = 4
  15. str_ungetbuf    = 5
  16. str_mode    = 6
  17. str_error    = 7
  18. str_bufptr    = 8
  19. str_flags    = 12
  20.  
  21. buf_read    = 12
  22.  
  23. _getchar:
  24. getchar_:    ; keine Parameter
  25.     pea _std__in
  26.     bsr.b _getc
  27.     addq.l #4,a7
  28.     rts
  29.  
  30. _getc:
  31. getc__P06stream:
  32. _fgetc:
  33. fgetc__P06stream:    ; Stack-Parameter: stream*
  34.     movem.l d1-d3/a0-a1/a6,-(a7)
  35.     move.l 6*4+4(a7),a0
  36.     clr.l -(a7)
  37.     move.l a7,d2
  38.     moveq #1,d3
  39.     bsr.b __Readfile
  40.     cmp.l #1,d0
  41.     beq.b fgok
  42.     moveq #-1,d0            ; "EOF"
  43.     bra.b fgret
  44. fgok    move.b (a7),d0
  45. fgret    addq.l #4,a7
  46.     movem.l (a7)+,d1-d3/a0-a1/a6
  47.     rts
  48.  
  49. __Readfile:    ; Stream a0, d3 Bytes nach d2, Anzahl der Daten nach d0
  50.     tst.b    str_ungetch(a0)
  51.     beq.b    rf0
  52.     subq.l    #1,d3
  53.     blo.b    rfret
  54.     exg    d2,a1
  55.     move.b    str_ungetbuf(a0),(a1)+
  56.     exg    d2,a1
  57.     clr.b    str_ungetch(a0)
  58.     bsr.b    rf0
  59.     addq.l    #1,d0
  60. rfret    rts
  61. rf0    move.l    str_bufptr(a0),d0
  62.     beq.b    __Readfile__NoBuf
  63.     move.l    d0,a0
  64.     move.l    buf_read(a0),a6
  65.     jmp    (a6)
  66. __Readfile__NoBuf:
  67.     move.l    #__Readflag,d0
  68.     beq.b    rfFile
  69.     btst    #6,str_flags(a0)
  70.     bne.b    rfFile
  71.     cmp.l    #_std__in,a0
  72.     bne.b    rfFile
  73.     move.l    d3,-(a7)
  74.     move.l    d0,a0
  75.     jsr    (a0)
  76.     move.l    (a7)+,d0
  77.     rts
  78. rfFile    ; gewöhnliche Datei ohne Buffer:
  79.     btst    #0,str_mode(a0)
  80.     beq.b    rfMurx
  81.     move.l    (a0),d1
  82.     beq.b    rfMurx
  83.     move.l    _DOSBase,a6
  84.     move.l    d3,-(a7)
  85.     move.l    a0,-(a7)
  86.     jsr    Read(a6)
  87.     move.l    (a7)+,a0
  88.     cmp.l    (a7)+,d0
  89.     beq.b    rf2
  90.     ; Dateiende oder Fehler:
  91. rf1    move.b    #-1,str_error(a0)
  92. rf2    rts
  93. rfMurx    moveq    #-1,d0
  94.     bra.b    rf1
  95.  
  96.     end
  97.  
  98.