| ??? 03/25/03 09:47 Read: times |
#42195 - RE: N Byte look up table Responding to: ???'s previous message |
Hello Sampah,
It is not a great code that I have - but will do the job alright. Here we go : ; FND_MAT is used to find the match in a look up table based on the contents ; of ACC when the routine is called. Calls SHO_NUM to display the 8 digit value. ; Each index points to the first digit of the eight digits. And each digit occupies ; one byte. ; Call with ACC holding the required Index and DPTR pointing to the LUT begining. ; ACC, DPTR, INDX, are all altered. FND_MAT: MOV INDX, #0FFH ; Initialize index for looping NXTINDX: INC INDX ; So that the first Index is a zero PUSH ACC ; Save ACC before checking end of table... CLR C MOV A, #250 ; Error if 250 records have been searched SUBB A, INDX ; and no match was found.... POP ACC JC ERROR ; Go display error INC DPTR ; Increment DPTR 8 times for eight digits INC DPTR INC DPTR INC DPTR INC DPTR INC DPTR INC DPTR INC DPTR CJNE A,INDX, NXTINDX ; Match found ? Loop back if not... LCALL SHO_NUM ; DPTR is now pointing to the required display digits.. RET ERROR: ( Routine to display error goes here ) SHONUM: ( Routine to display the eight digits goes here ) OK code gurus will scoff at the repeated INC DPTR statements. I just found this is as easy to handle as a modulo 8 loop. Maybe there are better ways to handle such a LUT - this is one among them. Hope to have been of help.( Sorry I never get my indents OK. But if you paste it in notepad it will line up OK ) Raghu |
| Topic | Author | Date |
| floating/3 byte number-lookup table | 01/01/70 00:00 | |
| RE: floating/3 byte number-lookup table | 01/01/70 00:00 | |
| RE: floating/3 byte number-lookup table | 01/01/70 00:00 | |
| RE: floating/3 byte number-lookup table | 01/01/70 00:00 | |
| RE: floating/3 byte number-lookup table | 01/01/70 00:00 | |
| N Byte look up table | 01/01/70 00:00 | |
| RE: N Byte look up table | 01/01/70 00:00 | |
| RE: N Byte look up table | 01/01/70 00:00 | |
| RE: N Byte look up table | 01/01/70 00:00 | |
| RE: N Byte look up table | 01/01/70 00:00 | |
| RE: N Byte look up table | 01/01/70 00:00 | |
RE: floating/3 byte number-lookup table | 01/01/70 00:00 |



