include IO.ASM s segment stack db 128 dup (?) s ends data segment B db 'Error! You entered more than 100 symbols! You must enter again and it must be less$' q db 'text is empty$' X db 101 dup (?) Src db 'Old text: $' Ru db 'Rule: $' New db 'New text: $' data ends com segment assume cs: com, ds: data, ss: s start: mov ax,data mov ds,ax ;Ââîä òåêñòà Re: outch '>' mov cx, 1 sub si, si Next: inch X[si] cmp X[si], '.' je EI cmp cx, 64h jae Ls inc cx inc si jmp Next Ls: lea dx, B outstr flush newline jmp Re EI: dec cx cmp si,0 jne EIp lea dx, q outstr flush newline jmp Re EIp: mov X[si], '$' lea dx, Src outstr lea dx, x outstr newline lea ax, x push ax call Prove lea dx, Ru outstr newline cmp ax, 1 jne LR2 lea ax, x push ax call Rule1 jmp End4 LR2: lea ax, x outstr push cx push ax call Rule2 End4: lea dx, New outstr lea dx, x outstr newline finish ;Function checks the property ;ax=1 - true. ax=2 - false Prove proc push bp mov bp, sp push bx push si sub si, si mov bx, [bp+4] CD: cmp [bx][si], byte ptr '0' jb N cmp [bx][si], byte ptr '9' ja p1 p1: cmp [bx][si], byte ptr 'A' jb N cmp [bx][si], byte ptr 'Z' ja p2 p2: cmp [bx][si], byte ptr 'a' jb N cmp [bx][si], byte ptr 'z' ja N inc si cmp byte ptr [bx][si], '$' jne CD mov ax, 1 jmp E1 N: mov ax, 2 jmp E1 E1: pop si pop bx pop bp ret 4 Prove endp Rule1 proc push bp mov bp, sp push bx push si push cx sub si, si mov bx, [bp+4] Next2: cmp [bx][si], byte ptr 'a' jb N2 cmp [bx][si], byte ptr 'z' ja N2 mov cx, 'a' sub [bx][si], cx mov cx, 'A' add [bx][si], cx N2: inc si cmp [bx][si], '$' jne Next2 pop cx pop si pop bx pop bp ret 4 Rule1 endp Rule2 proc push bp mov bp, sp push bx push si push cx push ax push dx push di mov di, [bp+6] mov bx, [bp+4] mov ax,di xor cx,cx mov cl,2 div cl add al,ah mov cl,al xor ch,ch outword ñx Next3: mov si,cx dec si mov dx,di sub di,cx push [bx][di] push [bx][si] pop [bx][di] pop [bx][si] mov di,dx loop Next3 pop di pop dx pop ax pop cx pop si pop bx pop bp ret 6 Rule2 endp com ends end start