;This program recives a string input from the user prints it back in segments .model small .stack 100h .data p = 50 ;maximum string support: 49 chars st_msg db 'Enter your string: ',0dh,0ah,'> $' in_str db p,0, 49 dup (0dh),'$' wStr db 23,0, 22 dup (0),'$' fin_msg db 'Press any key.$' count db ? pause dw ? pause1 dw ? .code init: mov ax,@data mov ds,ax mov ax,3 int 10h lea dx,st_msg ;prints out st_msg mov ah,9 ; int 21h ; lea dx,in_str ;read in_str mov ah,0ah ; int 21h ; call chrfix call newl call newl mov si,0 mov cx,p edit: cmp in_str+si+15,0dh ;stop condition je done call special ;creates one line lea dx,wStr ;print out the current wStr mov ah,9 ; int 21h ; mov dl,0dh ;returns to the beginning of the line mov ah,2 ; int 21h ; call wait1 inc si loop edit mov bp,0 done: mov in_str+si+15,' ' call special lea dx,wStr ;print out the current wStr mov ah,9 ; int 21h ; mov dl,0dh ;returns to the beginning of the line mov ah,2 ; int 21h ; call wait1 inc si inc bp cmp bp,16 jne done call newl call newl lea dx,fin_msg ;prints out fin_msg mov ah,9 ; int 21h ; mov ah,8 ;will cause the program to pause until the user presses any key int 21h mov ah,4ch ;return control to OS int 21h ;******************* wait1: mov pause,0ffffh agn1: mov pause1,0ffffh agn2: dec pause1 jnz agn2 dec pause jnz agn1 ret ;******************* special: mov count,16 ;the number of chars to be moved mov di,0 star1: mov wStr+di,'*' ;add 3 stars to the beginning of the line inc di cmp di,3 jne star1 agn: add di,si ;copies the values from in_str to wStr with the specific offset from si register sub di,3 mov dl,in_str+di sub di,si add di,3 mov wStr+di,dl inc di dec count jnz agn star2: mov wStr+di,'*' ;add 3 stars to the end of the line inc di cmp di,22 jne star2 ret ;******************* chrfix:mov cx,p-1 ;method that fixes extra chars that stick to the beginning of a string mov si,2 ; ! warning ! fix: mov al,in_str+si ; method cannot be nested! mov in_str+si-2,al ; inc si ; loop fix ; ret ;******************* cls: mov cx,25 ;method that clears the screen top: mov ah,2 ; ! warning ! mov dl,10 ; method cannot be nested! int 21h ; loop top ; ret ;******************* newl: mov ah,2 ;method that moves the cursor to the next line mov dl,10 ;drop 1 line int 21h ; mov dl,13 ;go to start of line int 21h ; ret end