Discussion in "8051 Discussion Forum" started by    nick    Jun 26, 2007.
Tue Jun 26 2007, 01:46 am
#1
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, 10:57 pm ]
Tue Jun 26 2007, 04:04 am
#2
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, 10:37 pm
#3
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
Nick
Wed Jun 27 2007, 02:26 am
#4
Nick,
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
Wed Jun 27 2007, 03:11 am
#5
Rickey
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.
P.S.
if you try the code now it will work cause I've corrected those mistakes.


[ Edited Sat Oct 20 2007, 11:06 pm ]
Wed Jun 27 2007, 02:42 pm
#6
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...
Load_add:
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
ret


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, 03:19 pm
#7
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, 03:23 pm
#8
Rickey
sorry here is the uploaded file.

You can open it using notepad as well.

Thanks million times
Mon Jul 02 2007, 12:45 pm
#9
Rickey,
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
regards,
Nick
Mon Jul 02 2007, 10:14 pm
#10
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.
Tips:
  • 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

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am