data segment ENG db 'SUNdayS Coming I Wanna Drive My Car,SUN,SUN$' ;9,3 sun1 db 'SUN' swcount db 0ah,0dh,'single word number:',?,?,'$' suncount db 0ah,0dh,'SUN:',?,'$' data ends code segment assume cs:code,ds:data,es:data start: mov ax,data mov DS, AX MOV ES, AX LEA DX, ENG is MOV AH, . 9 int 21H swcount1: MOV Al, ENG is [Si] CMP Al, ' $ ' ; is $ stop traversal JZ OUTPUT1 CMP Al, ' A ' JB text1 CMP Al , ' the Z ' JA text1 text2: CMP Al, ' S ' ; a string comparison of the letter S proceeds SUN JZ strcmp JMP Next text1: CMP Al, ' A ' JB addswc CMP Al, ' Z ' JNA Next addswc: inc is swcount [ 21 is ] ; not an alphabetic character is considered to be a separation between words, words plus a JMP Next to: POP Si the Next: INC. Si jmp swcount1 strcmp: the Push Si ; save Si LEA DI, Sun1 LEASi, ENG is [Si] MOV CX, . 3 REPZ CMPSB ; string comparison, this same character loop continues JNZ addcount inc is suncount [ . 6 ] addcount: JMP to OUTPUT1: inc is swcount [ 21 is ] or swcount [ 21 is ], 00110000b ; the value ascall converted into a corresponding code or suncount [ . 6 ], 00110000b LEA DX, swcount MOV AH, . 9 int 21H LEA dx,suncount int 21h exit: mov ah,4ch int 21h code ends end start
Not a big problem.