dseg segment strSrc db 'dsfa dfeagbedfc 9489dgj fk[q2tb hello world push',00h uLen1 dw $-strSrc-1 strSub db 'abcde',00h uLen2 dw $-strSub-1 uCount dw 0 dseg ends cseg segment assume cs:cseg, ds:dseg start: mov ax, dseg mov ds, ax mov es, ax xor bx, bx xor ax, ax ;================ ;===first step=== @main_loop: mov uCount, 0 lea si, strSrc cmp byte ptr si[bx-1], 00h jz @main_loop_end call find_word push bx push ax ;===second step=== mov cx, ax inc cx mov di, si add di, bx xor si, si lea bx, strSub @main_find_sym: push cx push di mov al, bx[si] repnz scasb jcxz @main_no_del inc uCount inc si cmp si, uLen2 jnz @main_second_loop ;===third step==== cmp si, uCount jnz @main_no_del ;===should be delete pop di pop cx ; call del_str jmp short @main_del @main_second_loop: pop di pop cx jmp short @main_find_sym @main_no_del: pop di pop cx @main_del: pop ax inc ax pop bx add bx, ax jmp short @main_loop @main_loop_end: mov ax, 4c00h int 21h ; Find word in string ; IN: ds:si ; offset to ASCIIZ string ; bx ; offset from the begining in string ; OUT: ax ; length of word find_word proc near push bx dx mov ax, bx @find_word_loop: mov dl, si[bx] inc bx test dl, dl jz @find_word_end cmp dl, ' ' jnz @find_word_loop @find_word_end: sub bx, ax mov ax, bx dec ax pop dx bx retn find_word endp cseg ends end start |