Thanks..... Its a long time since I have done "movc a,@a+dptr" with tables... I'm revisiting it now.
Thanks..... Its a long time since I have done "movc a,@a+dptr" with tables... I'm revisiting it now.
Last edited by Ian Rogers; 31st March 2012 at 02:07 PM.
I'd give my left arm to be ambidextrous
Nigel's tutorials in asm... http://www.winpicprog.co.uk/
Nigel's tutorials.. re-written in C. http://www.electro-tech-online.com/c...torials-c.html
I see EXACTLY what is going wrong. You're storing the values in code memory, and code memory cannot be directly addressed by the code.
The only way to read data values that are stored in code memory (such as you have with the db statements) is via indirect addressing by using "MOVC" instruction to read them from code memory. This is how we do look up tables on the 8051 -
Code :org 0x0080 Value movc A, @A+PC ret db 10 db 12
Then to call the table, you load the table line value into the accumulator, then call the subroutine -
Code :mov A,0x01 acall Value
You can also use DPTR as the offset register for this as well -
Code :org 0x0080 Value movc A, @DPTR+PC ret db 10 db 12
When it returns from the subroutine, the table line value will be stored in the accumulator.
In regards to your question regarding if instruction and data can fit in one byte. These are not PICs. They don't have a "long instruction word" like a PIC does. Instructions are 8 bit instructions and data is 8 bit data. 8051 uses what is called a "modified Harvard architecture". It's not a true Harvard processor like the PIC is.
Last edited by Jon Wilder; 31st March 2012 at 03:50 PM.
| Tags |
| Similar Threads | ||||
| Thread | Starter | Forum | Replies | Last Post |
| MCU 8051 family why don't we discuss | giaosucan | 8051/8951 | 7 | 30th July 2006, 08:02 PM |
| spec sheet for the 8051 MCU | mugzzzzy | Electronic Projects Design/Ideas/Reviews | 2 | 18th February 2004, 04:13 AM |
| need the 8051 instruction sheet | sinan mohammed | Datasheets, Manuals or Parts | 5 | 16th September 2003, 01:30 AM |
| 8051 and it`s family (8951,2051,......)and ADC0804 | massoti | General Electronics Chat | 2 | 1st April 2003, 03:14 PM |
| using 8051 as pulse counter | waqar | Electronic Projects Design/Ideas/Reviews | 0 | 13th March 2003, 04:06 PM |