home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / misc2 / filters.lzh / FECHO.ASM next >
Assembly Source File  |  1985-05-11  |  2KB  |  75 lines

  1.     Name fecho
  2.     Title
  3.     page    ,132
  4. comment /
  5.  
  6.     This program is a filter that reads from standard input and
  7.     echoes both to standard out and standard error output.  This
  8.     is useful when debugging filter sequences because it allows
  9.     you to view the intermediate data as the commands are executed.
  10.  
  11. /
  12. ;===================================================================
  13. code    segment    public
  14. ;===================================================================
  15. ;
  16. ;    command line is at 80h of psp - first byte is length
  17. ;
  18.     org    80h
  19. parmsize    db    ?
  20. parm        db    7fh dup (?)
  21. ;
  22. ; .com starts at 100h - but must jump around any data area
  23. ;
  24.     org    100h            ; com file starts here
  25.     assume    cs:code,ds:code,es:code
  26. fecho:
  27.     jmp    clear
  28. ;===================================================================
  29. ;
  30. ; data area for .com programs
  31. ;
  32. inchar      db    ?
  33. ;
  34. ;===================================================================
  35. clear:
  36. ;
  37. ; start of actual code is here (clear)
  38. ;
  39. ;
  40. ; These two i/o parameters are constants.
  41. ;
  42.     lea    dx,inchar    ; offset of inchar
  43.     mov    cx,1h        ; get 1 character
  44. again:
  45. ;
  46. ; read a character
  47. ;
  48.     xor    bx,bx        ; zero is handle of standard input
  49.     mov    ah,3fh        ; read a file/device function
  50.     int    21h        ; invoke the function
  51. ;
  52. ; if carry set of ax=0 exit
  53. ;
  54.     jc    oops        ; i/o error
  55.     and    ax,ax        ; set flags
  56.     jz    oops        ; eof
  57. ;
  58. ; now output to standard output
  59. ;
  60. output:
  61.     mov    bx,1h        ; standard output handle
  62.     mov    ah,40h        ; dx still points at inchar
  63.     int    21h        ; call dos output function
  64. ;
  65. ; now output to error output as an echo
  66. ;
  67.     mov    bx,2h        ; standard output handle
  68.     mov    ah,40h        ; dx still points at inchar
  69.     int    21h        ; call dos output function
  70.     jmp    again        ; repeat cycle
  71. oops:
  72.     int    20h        ; return to dos
  73. code    ends
  74.     end    fecho
  75.