;string operations
disp macro msg
lea dx,msg
mov ah,09h
int 21h
endm
.model small
.stack
.data
GLOBAL str1:byte,len1:byte
str1 db 25,?,25 dup('$')
msg0 db 10,13,'------MENU------$'
msg1 db 10,13,'1.INPUT $'
msg2 db 10,13,'2.LENGTH $'
msg3 db 10,13,'3.COMPARE $'
msg4 db 10,13,'4.SUBSTRING $'
msg4a db 10,13,'5.CONCATENATE $'
msg4b db 10,13,'6.OTHERS $'
msg5 db 10,13,'7.EXIT $'
msgn db 10,13,'$'
msg6 db 10,13,'ENTER STRING 1: $'
msg11 db 10,13,'LENGTH OF STRING 1: $'
msg13 db 10,13,'CONCATENATED STRING IS: $'
msgs db 10,13,'TOTAL SPACES : $'
msgw db 10,13,'TOTAL WORDS : $'
msgcap db 10,13,'TOTAL CAPS : $'
msgnl db 10,13,'TOTAL NEW LINE: $'
msga db 10,13,'TOTAL ALPHABET: $'
len1 db ?
cnt db 00h
cnts db 00h
cntw db 00h
cntc db 00h
cntn db 00h
cnta db 00h
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
EXTRN compare:far,substring:far,concatenate:far
m: disp msg0
disp msg1
disp msg2
disp msg3
disp msg4
disp msg4a
disp msg4b
disp msg5
disp msgn
mov ah,01h
int 21h
cmp al,'1'
je inp
cmp al,'2'
je len
cmp al,'3'
je comp
cmp al,'4'
je subs
cmp al,'5'
je con
cmp al,'6'
je oth
cmp al,'7'
je ex
inp: call input
jmp m
len: call leng
jmp m
comp: call compare ;compare
jmp m
subs: call substring ;substr
jmp m
con: call concatenate ;concatenate
jmp m
oth: call other
jmp m
ex: mov ax,4c00h
int 21h
endp main
;input
input proc near
disp msg6
mov ah,0ah
lea dx,str1
int 21h
ret
endp
;length
leng proc near
disp msg11
mov dl,str1+1
mov len1,dl
mov cnt,dl
call show
ret
endp
;counts
other proc near
lea si,str1+2
mov cl,len1
cw1: mov al,[si]
cmp al,'A'
jb cw2
cmp al,'Z'
ja cw2
inc cnta
inc cntc
cw2:
cmp al,'a'
jb cw3
cmp al,'z'
ja cw3
inc cnta
cw3:
cmp al,' '
jnz cw4
inc cnts
cw4:
cmp al,'.'
jnz cw5
inc cntn
cw5:
inc si
dec cl
jnz cw1
disp msga
mov ah,cnta
mov cnt,ah
call show
disp msgs
mov ah,cnts
mov cnt,ah
call show
disp msgcap
mov ah,cntc
mov cnt,ah
call show
disp msgnl
mov ah,cntn
mov cnt,ah
call show
disp msgw
add cnts,01h ;words would be 1 more than spaces
mov ah,cnts
mov cnt,ah
call show
ret
endp
;show pocedure
show proc near
mov al,cnt
mov ah,00h
mov cx,0000h
mov bx,000Ah
s1:
mov dx,0000h
div bx
push dx
inc cx
cmp ax,00h
jne s1
s2:
pop dx
add dl,30h
mov ah,02h
int 21h
dec cx
jnz s2
ret
endp
end
disp macro msg
lea dx,msg
mov ah,09h
int 21h
endm
.model small
.stack
.data
GLOBAL str1:byte,len1:byte
str1 db 25,?,25 dup('$')
msg0 db 10,13,'------MENU------$'
msg1 db 10,13,'1.INPUT $'
msg2 db 10,13,'2.LENGTH $'
msg3 db 10,13,'3.COMPARE $'
msg4 db 10,13,'4.SUBSTRING $'
msg4a db 10,13,'5.CONCATENATE $'
msg4b db 10,13,'6.OTHERS $'
msg5 db 10,13,'7.EXIT $'
msgn db 10,13,'$'
msg6 db 10,13,'ENTER STRING 1: $'
msg11 db 10,13,'LENGTH OF STRING 1: $'
msg13 db 10,13,'CONCATENATED STRING IS: $'
msgs db 10,13,'TOTAL SPACES : $'
msgw db 10,13,'TOTAL WORDS : $'
msgcap db 10,13,'TOTAL CAPS : $'
msgnl db 10,13,'TOTAL NEW LINE: $'
msga db 10,13,'TOTAL ALPHABET: $'
len1 db ?
cnt db 00h
cnts db 00h
cntw db 00h
cntc db 00h
cntn db 00h
cnta db 00h
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
EXTRN compare:far,substring:far,concatenate:far
m: disp msg0
disp msg1
disp msg2
disp msg3
disp msg4
disp msg4a
disp msg4b
disp msg5
disp msgn
mov ah,01h
int 21h
cmp al,'1'
je inp
cmp al,'2'
je len
cmp al,'3'
je comp
cmp al,'4'
je subs
cmp al,'5'
je con
cmp al,'6'
je oth
cmp al,'7'
je ex
inp: call input
jmp m
len: call leng
jmp m
comp: call compare ;compare
jmp m
subs: call substring ;substr
jmp m
con: call concatenate ;concatenate
jmp m
oth: call other
jmp m
ex: mov ax,4c00h
int 21h
endp main
;input
input proc near
disp msg6
mov ah,0ah
lea dx,str1
int 21h
ret
endp
;length
leng proc near
disp msg11
mov dl,str1+1
mov len1,dl
mov cnt,dl
call show
ret
endp
;counts
other proc near
lea si,str1+2
mov cl,len1
cw1: mov al,[si]
cmp al,'A'
jb cw2
cmp al,'Z'
ja cw2
inc cnta
inc cntc
cw2:
cmp al,'a'
jb cw3
cmp al,'z'
ja cw3
inc cnta
cw3:
cmp al,' '
jnz cw4
inc cnts
cw4:
cmp al,'.'
jnz cw5
inc cntn
cw5:
inc si
dec cl
jnz cw1
disp msga
mov ah,cnta
mov cnt,ah
call show
disp msgs
mov ah,cnts
mov cnt,ah
call show
disp msgcap
mov ah,cntc
mov cnt,ah
call show
disp msgnl
mov ah,cntn
mov cnt,ah
call show
disp msgw
add cnts,01h ;words would be 1 more than spaces
mov ah,cnts
mov cnt,ah
call show
ret
endp
;show pocedure
show proc near
mov al,cnt
mov ah,00h
mov cx,0000h
mov bx,000Ah
s1:
mov dx,0000h
div bx
push dx
inc cx
cmp ax,00h
jne s1
s2:
pop dx
add dl,30h
mov ah,02h
int 21h
dec cx
jnz s2
ret
endp
end
No comments:
Post a Comment