;Prompt user for input string up to 10 chars, echo back to user ;all storage on stack ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .model small .586 .stack 100h ;Set maximum stack size to 256 bytes .data msg db "Enter String (max 10 char): ",'$' .code START: mov ax, @data ;ax <-- data segment start address mov ds, ax ;ds <-- initialize data segment register mov dx, offset msg mov ah,09 int 21h mov ax,0ah ; max characters call mecho mov ax, 4c00h ;ax <-- 4c DOS 21h program halt function int 21h ;DOS service interrupt mecho proc push ds ;; save ds on stack since we want to use stack segment for storage push ax ;; save ax enter 0,0 mov ax,ss mov ds,ax ;; point data seg at stack seg mov ax,[bp+2] ;; restore ax add ax,2 ;; add two more bytes for size, returned length sub sp, ax ;; allocate space on stack for string mov dx,sp mov si,sp ;; point dx,si at storage area mov [si],al ;; set up maximum size mov ah,0ah int 21h ;; get string from user call pcrlf mov cl,[si+1] ;; get characters entered xor ch,ch ;; cx = char count add si,2 ;; point si at start of string lp: lodsb ;; get byte call pchar ;; print it out loop lp leave ;; restore bp pop ax ;; restore ax pop ds ;; restore ds ret mecho endp pcrlf proc ;; print out crlf mov ah,2 mov dl, 0ah int 21h mov dl, 0dh int 21h ret pcrlf endp pchar proc ;; print char in al mov dl,al mov ah,2 int 21h ret pchar endp END START