| ??? 02/17/06 12:08 Read: times |
#110224 - Thats the way it works Responding to: ???'s previous message |
The 8051 (not the assembler) only has the instruction movc a,@a+dptr. You are correct in assuming adding 0 to the dptr in this code does not affect the dptr - so why do it? Because that what the instruction does! We have no choice in the matter - there is no movc a,@dptr instruction. We could have written your sample code like this: mov dptr,#hello_str call pstring pstring: mov r7,#0 ;reset index ps1: mov a,r7 ;get index into A movc a,@a+dptr ;a= (dptr[R7]) jz ps_x ;if char == 0, exit mov P1,a ;else copy to P1 inc r7 ;R7++ sjmp ps1 ;try for another character ps_x: ret hello_str db "Hello world",0 In this instance the DPTR is the base pointer and R7 becomes the index. The limitation of this implementation is that a string can only be a maximum of 255 characters long and we use R7. My preferred way was your original code in using the DPTR as the index pointer. |
| Topic | Author | Date |
| MOVC A , @A+DPTR | 01/01/70 00:00 | |
| Thats the way it works | 01/01/70 00:00 | |
| its because its..... | 01/01/70 00:00 | |
| MOVC A , @A+DPTR | 01/01/70 00:00 | |
| Re: | 01/01/70 00:00 | |
| Re | 01/01/70 00:00 | |
| Re: | 01/01/70 00:00 | |
| A does not have to be 0 | 01/01/70 00:00 | |
| It can be convenient ... | 01/01/70 00:00 | |
| velocity | 01/01/70 00:00 | |
| I'm not so sure... | 01/01/70 00:00 | |
| Be carefull | 01/01/70 00:00 | |
Re: | 01/01/70 00:00 | |
| How I use that MOVC | 01/01/70 00:00 |



