tab equ $09 ; ASCII code of tab sp equ $20 ; ASCII code of space character cr equ $0D ; ASCII code of carriage return lf equ $0A ; ASCII code of line feed period equ $2E ; ASCII code of period comma equ $2C ; ASCII code of comma semicolon equ $3B ; ASCII code of semicolon exclamation equ $21 ; ASCII code of exclamation null equ $0 ; ASCII code of NULL character org $1000 match rmb 1 org $1500 clr match ldx #string_x loop ldab 1,x+ ; the following 10 instructions skip white spaces to look for the next word in string_x tstb beq done cmpb #sp beq loop cmpb #tab beq loop cmpb #cr beq loop cmpb #lf beq loop ; the first nonwhite character is the beginning of a new word to be compared ldy #word_x ldaa 1,y+ next_ch cba bne end_of_wd cmpa #null ; check to see if the end of word is reached beq matched ; " ldaa 1,y+ ; get the next character from the word ldab 1,x+ ; get the next character from the string bra next_ch ; the following 10 instructions check to see if the end of the given word is reached end_of_wd cmpa #null bne next_wd cmpb #cr beq matched cmpb #lf beq matched cmpb #tab beq matched cmpb #sp beq matched cmpb #period beq matched cmpb #comma beq matched cmpb #semicolon beq matched cmpb #exclamation beq matched ; the following 11 instructions skip the remaining characters in the unmatched word next_wd ldab 1,x+ beq done cmpb #cr lbeq loop cmpb #lf lbeq loop cmpb #tab lbeq loop cmpb #sp lbeq loop bra next_wd matched ldab #1 stab match done swi string_x fcc "This string contains certain number of words to be matched." fcb 0 word_x fcc "This" fcb 0 end