??? 03/10/04 08:51 Read: times |
#66395 - RE: I need help Responding to: ???'s previous message |
Here is a sample of accessing a table > 256 bytes done in both C code and in assembly code.
// C CODE VERSION #define TABLE_SIZE 1024 char code table2[TABLE_SIZE]= /* setup the table and */ {0x55, 0x34, 0xAA, 0x32, 0x99, /* ............ initialize part of it */ 0x21, 0x32, 0x75, 0x54, 0xA3}; // subroutine to look up one element from the table2 of byte // values and return the byte value. the entry argument is // a pointer to the index to fetch from. char lookup2(unsigned int index) { return(table2[index]); } ; ASSEMBLER CODE VERSION TABLE3: DB 055H, 034H, 0AAH, 032H, 099H DB 021H, 032H, 075H, 054H, 0A3H ; ......... initilize all the entries DB 000H, 000H, 000H, 000H, 000H ; SUBROUTINE TO LOOKUP ONE ELEMENT OF TABLE3 OF BYTE ; VALUES AND RETURN THE BYTE VALUE IN THE A REGISTER ; THIS HAS THE INDEX OF THE ARRAY IN R6::R7 LOOKUP3: MOV A,#LOW (TABLE3) ; get address of table3 + R6::R7 ADD A,R7 ; into DPTR MOV DPL,A MOV A,#HIGH (TABLE3) ADDC A,R6 MOV DPH,A CLR A MOVC A,@A+DPTR ; fetch table element to A reg RET Good Luck Michael Karas |
Topic | Author | Date |
C Programe for 8051 | 01/01/70 00:00 | |
Reading List | 01/01/70 00:00 | |
RE: Reading List | 01/01/70 00:00 | |
RE: C Programe for 8051 | 01/01/70 00:00 | |
Sorry for the new thread | 01/01/70 00:00 | |
I need help | 01/01/70 00:00 | |
Learning 'C' | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: C table lookup | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help | 01/01/70 00:00 | |
RE: I need help![]() | 01/01/70 00:00 |