;This program counts the number of (English) words found in a string
;which is exactly one sentence long.  The word is held in a string
;which begins in location 200h. At 200h is a byte which indicates
;the length of the string - in the same manner as Turbo Pascal.
;Example:  200h = 19(dec) 
;          and starting at 201h = 'This is a sentence.'
;  In the example, you would set CX to be 4
;  Note:  there are no other punctuation or other characters other
;         than the period
;  Solution:  count the number of spaces + 1
        mov     si,     201h    ;point si to the first character in string
        mov     bl,     byte ptr 200h   ;grab length of string
        mov     bh,     0       ; convert length into a word
        mov     di,     201h
        add     di,     bx      ;compute last byte of string
        dec     di              ;di now points to last byte
        mov     cx,     0       ;count of number of bytes
lp:     cmp     si,     di
        ja      finish
        cmp     byte ptr 0 [si], ' '    ;is it a blank/space??
        jne     nxtbyte
        inc     cx              ;yes -- a blank.  Count it.
nxtbyte: add    si, 1
        jmp     lp
finish: inc     cx              ;num of blanks plus 1 = num of words
        int     20h