0% found this document useful (0 votes)
18 views1 page

Q#6

Uploaded by

Muhammad Taaha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

Q#6

Uploaded by

Muhammad Taaha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

include irvine32.

inc
.data
origin byte "Original string: ",0
convert byte "Trimmed string: ",0
my_string byte "##ABC",0
.code
string_trim proto string:ptr byte,character:byte
main proc
mov edx,offset origin
call writestring

mov edx,offset my_string


call writestring
call crlf
invoke string_trim, addr my_string,'#'
mov edx,offset convert
call writestring
mov edx,offset my_string
call writestring
call crlf
call crlf
exit

main endp
string_trim proc uses esi edi,string:ptr byte,character:byte
mov esi,string
mov al,character

trimming:
mov dl,[esi]
cmp dl,0
je done
cmp dl,al
jne done
inc esi
jmp trimming
done:
mov edi,string

shift_loop:
mov dl,[esi]
mov [edi],dl
cmp dl,0
je completed

inc esi
inc edi
jmp shift_loop
completed:

ret
string_trim endp
end main

You might also like