;This program recives a string input from the user and "corrects" it - first letter becomes upper case, all others become lower case .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), '$' fin_msg db 'Press any key.$' pause dw ? pause1 dw ? .code init: mov ax,@data mov ds,ax mov ax,3 int 10h lea dx,st_msg ;prints out st_str mov ah,9 ; int 21h ; lea dx,in_str ;read in_str mov ah,0ah ; int 21h ; call chrfix call newl mov si,0 cmp in_str+si,'@' ;first char is @, skip all steps je done cmp in_str+si,'a' ;first letter is already upper case, skip next step jb lower ; sub in_str+si,32 ;will cause the first letter to become upper case lower:mov cx,p-2 ;check the entire string agn: inc si ; cmp in_str+si,' ' ;skip checks for special chars (space, line feed) je low ; cmp in_str+si,0dh ; je low ; cmp in_str+si,'Z' ;checks for upper case jae low ; add in_str+si,32 ;turns upper case to lower case low: loop agn ; done: lea dx,in_str ;print out the fixed in_str mov ah,9 ; int 21h ; 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 ;******************* 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 ;******************* 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