User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 391,682 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,188 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser:
Views: 553 | Replies: 5 | Solved
Reply
Join Date: May 2008
Posts: 3
Reputation: mihal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mihal mihal is offline Offline
Newbie Poster

comparing 2 strings

  #1  
May 21st, 2008
Ok, so far i have 2 strings inputed from keyboars into stringA and stringB, defined as db
now i need to count how many times is string B appearing in A and output that number.
Max lenght of strings is 29.
I think it should be done in 2 loop, to run throgh bouth string,
Can anyone help?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,261
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 20
Solved Threads: 368
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: comparing 2 strings

  #2  
May 21st, 2008
That sounds like a reasonable approach.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Reply With Quote  
Join Date: May 2008
Posts: 3
Reputation: mihal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mihal mihal is offline Offline
Newbie Poster

Re: comparing 2 strings

  #3  
May 21st, 2008
thats fine but now in need to print di which i uses as a counter, how to do it?
Reply With Quote  
Join Date: Mar 2008
Posts: 26
Reputation: JobMatchNow is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
JobMatchNow JobMatchNow is offline Offline
Light Poster

Re: comparing 2 strings

  #4  
May 21st, 2008
Is two loops even alot?
Reply With Quote  
Join Date: Dec 2005
Posts: 3,261
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 20
Solved Threads: 368
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: comparing 2 strings

  #5  
May 21st, 2008
Well you use 'divide by 10' and 'modulo 10' to extract each digit from the number, then add '0' to the result to get a printable character.

123 / 10 = 12
123 % 10 = 3
Take the 3, add '0' to it to get '3'
The only minor problem being that it gives you the digits in reverse order, but that shouldn't be that hard to solve.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Reply With Quote  
Join Date: May 2008
Posts: 3
Reputation: mihal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mihal mihal is offline Offline
Newbie Poster

Re: comparing 2 strings

  #6  
May 29th, 2008
Jeah in other words pul it all on Stack I used somthing simmilar:
First it writes message, then prints counter. Hers the code hope it helps someone, cheers



Print|Count proc far
push si
push ax

mov dx,offset message1
mov ah,09
int 21h

mov bx,10

mov si,2
mov ah,0
mov al,counter

Base10:

mov dx,0 ; zero devide
div bx
add dx,48
mov rez1+[si],dl;
dec si
cmp ax,0
jne Base10

mov dx,offset rez1
mov ah,09
int 21h

pop ax
pop si
ret
ispisbrojaca endp
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Assembly Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 2:21 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC