| ??? 10/19/01 04:00 Read: times |
#15855 - RE: Converting my o/p to drive LCD disp |
that will always print the first message when you call search_table.
next you'll want to modify it to allow you to select any message in the table. since you only require sequential display, code that up first and then think about a more selective accessing method. one way to sequence through your entire table would be to change the 0h termination senitinal into a pause-for-display sentinal. now you'd have another special character test. its match would trigger a call to a long viewing delay time... maybe 2 to 4 seconds. you could use a 1h or anything you'll never require as a character. another way to handle this would be to leave the search_table code alone but modify the way it is called elsewhere in your program. for example. lets say you force the calling location to load dptr BEFORE calling search_table(). of course you must remove the MOV DPTR,#**** so any carefully prepared dptr value would result in the proper string printed from the table. You could use a accumulator in the same way (looks like you started off that way) but you'd have to do some extra work to push beyond a 256 byte page limit. lets assume you choose to modify dptr prior to calling search_table: now you can do a lot of hard work equating a bunch of entry points into the table but that would be a lot of work. in programming, anything that takes a lot of repetitive work is a clue that a better approach can be found when you have the time. :) probably the simplest next step is to do something j.guy wrote about previously and calculate the starting address to be loaded into dptr, by taking a line number and multiplying it times the fixed line message byte count (9 = eight characters + 1 termination sentinal). so your algorithm would be to print line Y: dptr=#table + (9*Y) this can get a little ugly for a novice but you can use a memory map trick to simplify: if your place your table at address 0100h then whatever you calculate for 9*Y would be loaded into dptr and then dph would be incremented to load the 0100 as the start of table. you might need to think that out a bit. I'll skip ahead to multiplying 9*Y where Y is a legal number from 0 for the first line to 255 for the maximum line count. i haven't yet unpacked my 8051 bible so the following could need some syntax correction :) assume the line number is loaded in reg R2: ;----- mov a,r2 mov b,#9 mul a,b mov dph,a mov dpl,b call search_table;----- now you can alter how line number variable R2 is changed to print in either direction or by skipping several lines. its up to your imagination. have fun experimenting with that. at some point, look to your LCD routines for repeating patterns and consider how to make a reusable subroutine for them. it reduces code and improves readability. duh |



