home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PCACHSRC.ZIP / DSKSCRNB.ASM < prev    next >
Assembly Source File  |  1990-07-12  |  3KB  |  66 lines

  1. ;DSKSCRNB.COM           B.Kauler 1989.
  2. ;reads a text file from disk and displays it on the screen.
  3. ;DOS command line:  DSKSCRNB <filename >CON
  4. ;This method uses standard input and standard output, with
  5. ;redirection specified on the DOS command-line tail.
  6. ;Input is redirected from the keyboard to a file, and output
  7. ;need not be redirected since standard output is the screen.
  8. ;...therefore >CON is optional.... you could as an exercise
  9. ;try >PRN for output redirection.
  10. ;................................................................
  11. comseg  segment
  12.         assume  cs:comseg,ds:comseg,ss:comseg
  13.         org     100h
  14. main    proc    far
  15.         jmp     code_starts
  16. ;................................................................
  17. ;data here.....
  18. char_pos   db   0               ;character position on the line.
  19. ;................................................................
  20. code_starts:
  21. ;read a character....
  22. ;note that we test for input status, as a file does not necessarily
  23. ;end with CTRL-Z.  This function sees if there is another character
  24. ;to be read, and if not returns AL=0.
  25. again:  mov     ah,0Bh          ;INPUT_STATUS.
  26.         int     21h             ;       /
  27.         cmp     al,0
  28.         je      eof
  29. ;The standard input device is specified on the DOS command line...
  30.         mov     ah,7            ;STANDARD_INPUT
  31.         int     21h             ;       / (-->AL).
  32. ;process the character....
  33.         cmp     al,1Ah          ;is it CTRL-Z?
  34.         je      eof
  35.         cmp     al,09h          ;is it TAB?
  36.         je      tab
  37.         call    disp_char       ;display the char.
  38.         inc     char_pos        ;update current char position.
  39.         cmp     al,0Ah          ;test if end of line.
  40.         jne     again           ;not end of line--get next char.
  41.         mov     char_pos,0      ;clear char count.
  42.         jmp     again           ;get next char.
  43. ;..................................................................
  44. tab:    mov     al," "
  45.         call    disp_char       ;display a blank.
  46.         inc     char_pos        ;update current char position.
  47.         test    char_pos,7      ;are we at a TAB stop?
  48.         jz      again           ;yes.
  49.         jmp     tab
  50. ;.................................................................
  51. eof:    mov     al,0            ;return to DOS.
  52.         mov     ah,4Ch          ;       /
  53.         int     21h             ;       /
  54. main    endp
  55. ;.................................................................
  56. disp_char       proc    near
  57. ;send character to the standard output device....
  58.         mov     ah,2            ;STANDARD_OUTPUT.
  59.         mov     dl,al           ;       /
  60.         int     21h             ;       /
  61.         ret
  62. disp_char endp
  63. ;................................................................
  64. comseg  ends
  65. end     main
  66.