home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT7 / GETSTR.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-08-27  |  1.5 KB  |  33 lines

  1. ;
  2. ;       Program GetStr ( Chapter 7 )
  3. ;
  4.     page    55,132
  5. .model  small
  6. .stack
  7. .data
  8. OutStr  db      0Dh,0Dh,'<<<=== The text read: ===>>>',0Dh,0Ah
  9. StrBuf  db      32767 dup (?)           ; Buffer for string to be read
  10. StrBufE label   byte
  11. .code
  12. .startup
  13. IsOpen: mov     bx,0                    ; Store handle code into BX
  14.     mov     cx,StrBufE-StrBuf       ; Max number of symbols to be read
  15. GetNext:mov     ah,3Fh                  ; Function 3Fh - Read File or Device
  16.     lea     dx,StrBuf               ; DS:DX point to String Buffer
  17.     int     21h                     ; DOS service call
  18.     jnc     TstStr                  ; If NO CARRY - string is read
  19.     mov     al,ah                   ; Set ErrorLevel to Read Error Code
  20.     jmp     ExProg                  ; Exit the program
  21. TstStr: cmp     ax,3                    ; Is there any characters apart CR,LF?
  22.     jb      Compl                   ; If not, terminates the work
  23.     mov     di,ax                   ; DI points at the end of text read
  24.     mov     StrBuf[di],'$'          ; Append End Of Message for service 09h
  25.     lea     dx,OutStr               ; DS:DX - address of text to be output
  26.     mov     ah,09                   ; function 09h - output text string
  27.     int     21h                     ; DOS service call
  28.     jmp     GetNext                 ; Read next string
  29. Compl:  mov     al,0                    ; Set ErrorLevel to 0
  30. ExProg: mov     ah,4Ch                  ; Function 4Ch - terminate process
  31.     int     21h                     ; DOS service call
  32.     end
  33.