Advertisement
MichaelPetch

DOS buffered input

Sep 15th, 2022 (edited)
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. .model small
  2. .stack 100h
  3. .data
  4. ; First byte of buffer is number of characters to read (including Carriage Return)
  5. ; Second byte will be the number of bytes read (not including the Carriage Return).
  6. buffer db 9, 0, 9 dup("$")
  7.  
  8. .code
  9. main proc
  10. mov ax,@data
  11. mov ds,ax
  12.  
  13. LEA dx,buffer ; Read input. see: http://www.ctyme.com/intr/rb-2563.htm
  14. mov ah,0Ah
  15. int 21h
  16.  
  17. ; Set BX to index of the Carriage Return in the buffer
  18. mov bh, 0 ; Upper part of BX set to 0
  19. mov bl,[buffer+1] ; [buffer+1] contains the nu,ber of chars read excluding Carriage Return
  20.  
  21. mov [buffer+bx+2], '$' ; Replace the Carriage Return by a $ (end of string)
  22.  
  23. LEA dx,buffer+2 ; Print out the string entered
  24. mov ah,09h
  25. int 21h
  26.  
  27. LEA dx,buffer+2 ; Print out the string entered
  28. mov ah,09h
  29. int 21h
  30.  
  31. mov ah,4ch
  32. int 21h
  33. main endp
  34. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement