Guest User

Untitled

a guest
Apr 10th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.     string db 80 dup(" ")   ; Hold up to 80 characters
  3.     str_length dw -1    ; Must start on -1 as return key is a character
  4.     char db ?
  5.  
  6. proc readString
  7.     push ax bx
  8.     clc    
  9.     mov bx, OFFSET string      
  10. next_char:
  11.     call readChar
  12.     jc done
  13.     mov al, char
  14.     mov [bx],al
  15.     inc bx
  16.     jmp next_char
  17. done:
  18.     pop bx ax
  19. ret
  20. endp readString
  21.            
  22. proc readChar
  23.     push ax
  24.  
  25.     mov ah,1
  26.     INT 21H
  27.     mov char,al
  28.            
  29.     cmp char, 13    ; IS IT RETURN CHARACTER??
  30.     jnz done2
  31.     stc     ; Set the Carry Flag
  32.  
  33. done2: 
  34.     inc str_length   ; Keep track of how many characters are entered
  35.     pop ax
  36. ret
  37. endp readChar
Add Comment
Please, Sign In to add comment