Discussion in "8051 Discussion Forum" started by    nick    Jun 25, 2007.
Mon Jun 25 2007, 08:16 PM
Hi to everyone,
I have a project that i will describe hereunder
I connect to the 8051 development board through RS232 serial port.
The code that I've written checks the word entered from hyper terminal compares it to the list that I've defined on my code and returns The word has been found on the hyperterminal.
I'll paste the code down here.
from the code you will see for example if i want to add 100 words i have to write 100 NEXT routines. My question is can it be done with only one routine and for example if i decide to type on hyper terminal the word beauty can it find it from the word beautyfull.

Code Removed! to save the page space...

Thanks in advance

[ Edited Wed Jun 27 2007, 05:27 PM ]
Mon Jun 25 2007, 10:34 PM
yes its possible. well you do this way.. like first receive the complete word till user press enter key..
and then append the word with 0x00 so that u know that this is end of string..
and comparing can be done after you done receiving, is it mandatory to use interrupts? because lock step can be better option in this.. think and tell me
Tue Jun 26 2007, 05:07 PM
Hi Rickey, well thanks very much for the reply but as mentioned I'm a new bee in assembler and I just started doing some simple things using the code that I've posted.

If it's possible to amend my code it is not necessary using interrupts but If u can change my code and adapt it to do what i need I would be very thankfull to you I would appreciate it very very much.

In that way I can learn some more regarding assembler steps and procedures
Million thanks in advance
Tue Jun 26 2007, 08:56 PM
as i say to everyone that i don't give codes but i help you to reach what you looking for
so.. i will give you steps to modify your code..
but first of all.. i don't think you've tested your code... did you compile it? it must be giving you errors..
i list few of them here..
the label List1,2,3,4 does not exist.
Label exit is being used twice..
and.. some missing labels like AGAIN

some silly mistakes are there.. you need to edit them..
like... in subroutine outchar, you are actually doing polling even though interrupts are enabled!!
so... Nick please review your code once again.. and upload the file (dont paste)
Some useful hint:
Try not to modify PCON, only do when necessary.
Check vaule in SCON
no need to change priority of interrupts if not necessary
try using polling method when you are not doing anything else with your controller.
and nick next time if you want to put the code.. upload it instead of pasting it
Tue Jun 26 2007, 09:41 PM
I've translated the code from my mother tongue to English so there were some silly mistakes you are absolutely right.
I've corrected them and I will upload the file.
This code how it is now it will work I tested it and I now this works. But I think you did not understand my question very well.
The code does the job, you will see the routines Next1, Next2 and Next3. I can add another list for ex, LIST5 DB '5HELLO' but then i have to add a routine Next4 in order that the program checks the LIST5 as u see from the code. I didn't ask from you to put the code, I've kindly requested to modify it if you can so that I don't have to add routine Next(x) hundred times if i want the program to check 100 words.

This is all I asked for a modification not the whole code from you.

Thanks again.
if you try the code now it will work cause I've corrected those mistakes.

[ Edited Sat Oct 20 2007, 05:36 PM ]
Wed Jun 27 2007, 09:12 AM
hey nick, i am still getting error in your program, its not the programming error, its the logical error, you might be returning from some subroutine in a wrong way.
and the label EXIT is being used twice..
if you think that problem is in my simulator and your program is correct then, i tell you the steps to modify your code to get the desired result.

As you have made list of strings, now you make list of string pointers in assembly like below..
ponters: DW    LIST1,LIST2,LIST3...

this way you can store as many stings in a single list.
and to use load addresses one by one..
do like this...
movc a,@a+dptr
mov r7,a
inc dptr
movc a,@a+dptr
mov r6,a
inc dptr
;now save the current pointer position..
mov 40H,dpl
mov 41H,dph
;now load the new address
mov dpl,r6
mov dph,r7

and put the comparing part in a new subroutine. and you load the addresses using the above subroutine.. the above routine can be called something like this...
mov dpl,40H
mov dph,41H
lcall load_address

and for the first time calling the load address routine, simply use..
mov dptr,#pointers

Hope this is helpful for you..
don't forget to click thanks!
 nick like this.
Wed Jun 27 2007, 09:49 AM
Hi Rickey, thanks again for the reply I coudn't try it yeat .But I'll try it and tell you how it went.
As it matters for the code. I'll load the original code that I've writen it will be in my mother tongue but i think you are very capable of getting the procedure you will know what happens.
The Code is in .a51 and i use MIDE for writing and compiling. I ve compiled it writ know and it did not give me any errors.
As it matters for the DW as soon as i put a DW on the code it tells me that it is not defined.

I'll send the code, please if you have time compile it and inform me if it works.
Then you have the DB'defined and if you type any of the words that are defined in those tables (LISTA1 and so on) on the hyper terminal the you will get back KERKIMI ESHTE KRYER ME SUKSES, FJALA ESHTE GJETUR which means that the search was succsesfuly completed the word was found.

As I mentioned it does the job but any time i want to add another word i have to add another procedure for checking the next word.
And I also need this program to find no matter how many words I add with only one procedure as well as finding the short word in long word. EX there is word '6BESNIK' defined on one of the lists "and if i type only NIK i need the code to find this part of the word from BESNIK.
Thanks again I really appreciate it.
And I think this forum is the best regarding 8051 projects.
Wed Jun 27 2007, 09:53 AM
sorry here is the uploaded file.

You can open it using notepad as well.

Thanks million times
Mon Jul 02 2007, 07:15 AM
I've followed your instruction but the code does not do what i want still.
I can upload the code if you want.
What I need from the code is : I should be able to add as many strings as I want and the code should compare them and also find the short word in large one EX. If the word Beautiful is present on the LIST if i type Beauty on hyper terminal the code should find it from the word beautifyl
Mon Jul 02 2007, 04:44 PM
Hi nick,
i checked your code and is working. but not as you want. the reason is you implemented everything in a straight way method. i mean to say... like even while storing the word you are giving the length of word along. so that is not a good thing.
And i really dont prefer to give you the direct code to make that thing work. so.. i want you to work a little hard..
as i already told you... receive the char string.. and append it with 00, so easy to store. no need to count like you are counting with R4.
So keep receiving and when you receive '=' append this '=' with 00H i mean write that location with 00H

and.. what i want you to do is.. write a simple program to compare two strings ending with 00H.
  • Check both the stings for 00H
  • if any of them reaches the 00 value, you break out giving the answer.. not equal.
  • and if any of the word is equal, in a big word you give the answer equal.

Now.. while comparing.. you do these things in mind..
if any of the string reaches 00H you break out.
if sting matches completely when you reach 00H of the i/p string the answer should be equal.. that means.. you must check the i/p string first for the 00H value.. then the second one.
so i want you to write this program to compare words. both ending with 00H
and do every possible combination. Hope to hear good from you
 nick like this.

Get Social


Powered by e107 Forum System


Sat May 15 2021, 11:47 AM
Derek Wolcott
Geometric Energy Corporation announced the dogecoin-funded mission on Sunday, with DOGE-1 representing a 40 kilogram cube satellite flying as a payload on a Falcon 9 rocket.
Thu May 13 2021, 07:18 PM
Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I get actually enjoyed account your blog posts. Any way I will be subscribing to your augment and even I achievement you access consistently quickly. https://mkfinstitute.com Trisha Trisha
Wed May 12 2021, 01:23 PM
Jed Roan
Now you can promote your site all over the internet for FREE: http://www3.listofsitesthatacceptfreeads.club
Wed May 12 2021, 08:20 AM
If some one wants to be updated with most recent technologies afterward he must be visit this web page and be up to date every day. annual credit report https://creditscoresetf.com
Wed May 12 2021, 06:11 AM
Great website. A lot of useful information here. I'm sending it to some pals ans also sharing in delicious. And of course, thanks on your effort! annual credit report https://creditscorecheckn.com



Thu Jun 25 2020, 03:46 PM
Mon Jun 22 2020, 03:03 PM
Tue Jun 16 2020, 05:10 PM
Sat Jun 13 2020, 09:43 PM
Thu May 21 2020, 12:44 PM
Thu May 21 2020, 01:28 AM
Wed May 20 2020, 07:05 PM
Wed May 20 2020, 11:52 AM


Guests: 105, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123