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

  1. ;DSKSCRNC.COM           B.Kauler 1989.
  2. ;reads a text file from disk and displays it on the screen.
  3. ;DOS command line:  DSKSCRNC [drive][path]filename
  4. ;Uses modern handles method.  Allows path to precede filename.
  5. ;................................................................
  6. comseg  segment
  7.         assume  cs:comseg,ds:comseg,ss:comseg
  8.         org     100h
  9. main    proc    far
  10.         jmp     code_starts
  11. ;................................................................
  12. ;data here.....
  13. handle     dw   0               ;identifies file.
  14. dta        db   0               ;Disk Transfer Area.
  15. char_pos   db   0               ;character position on the line.
  16. filespec   db   32 dup (0)      ;DOS command-tail goes here.
  17. errmsg     db   "file access error!!!!$"
  18. ;................................................................
  19. code_starts:
  20. ;first job is to get the command-tail into FILESPEC...
  21.         call    get_filespec
  22. ;open the file....
  23.         mov     dx,offset filespec
  24.         mov     al,0
  25.         mov     ah,3Dh
  26.         int     21h
  27.         jc      error           ;carry-flag set if error.
  28.         mov  handle,ax
  29. ;read a character....
  30. again:  mov     bx,handle
  31.         mov     cx,1            ;just read one character.
  32.         mov     dx,offset dta   ;destination is DTA.
  33.         mov     ah,3Fh          ;READ_HANDLE.
  34.         int     21h             ;       /
  35.         jc      error           ;carry-flag set if error.
  36.         cmp     ax,0
  37.         je      eof             ;end of file if AX=0.
  38.         ;note that the file-pointer is updated by function3Fh.
  39. ;process the character....
  40.         mov     al,dta          ;put the char in AL.
  41.         cmp     al,1Ah          ;is it CTRL-Z?
  42.         je      eof
  43.         cmp     al,09h          ;is it TAB?
  44.         je      tab
  45.         call    disp_char       ;display the char.
  46.         inc     char_pos        ;update current char position.
  47.         cmp     al,0Ah          ;test if end of line.
  48.         jne     again           ;not end of line--get next char.
  49.         mov     char_pos,0      ;clear char count.
  50.         jmp     again           ;get next char.
  51. ;..................................................................
  52. tab:    mov     al," "          ;assume tab-stops every 8th column.
  53.         call    disp_char       ;display a blank.
  54.         inc     char_pos        ;update current char position.
  55.         test    char_pos,7      ;are we at a TAB stop?
  56.         jz      again           ;yes.
  57.         jmp     tab
  58. ;.................................................................
  59. eof:    mov     ah,3Eh          ;CLOSE_HANDLE.
  60.         int     21h             ;       /
  61.         jc      error
  62.         mov     al,0            ;return to DOS.
  63.         mov     ah,4Ch          ;       /
  64.         int     21h             ;       /
  65. ;.................................................................
  66. error:  mov     dx,offset errmsg ;display error message.
  67.         mov     ah,9             ;      /
  68.         int     21h              ;      /
  69.         mov     al,0             ;could return an error code.
  70.         mov     ah,4Ch
  71.         int     21h              ;back to DOS
  72. main    endp
  73. ;.................................................................
  74. get_filespec    proc    near
  75.         cld
  76.         mov     si,082h         ;point to command-tail in PSP.
  77.         mov     di,offset filespec ;point to destination.
  78. read_next: lodsb
  79.         cmp     al,0Dh          ;is char a carriage-return.
  80.         je      end_string
  81.         stosb
  82.         jmp     read_next
  83. end_string: ret
  84. get_filespec endp
  85. ;.................................................................
  86. disp_char       proc    near
  87. ;By default the standard output is the screen....
  88.         mov     ah,2            ;STANDARD_OUTPUT.
  89.         mov     dl,al           ;       /
  90.         int     21h             ;       /
  91.         ret
  92. disp_char endp
  93. ;................................................................
  94. comseg  ends
  95. end     main
  96.  
  97.