Hi All, I'm facing a problem with assembly coding here..
CSEG AT 0100H LABEL: DB "TESTING TESTING 1 2 3]" TRANS: MOV DPTR,#LABEL ;load data pointer with LABEL's address MOV R0,DPL LJMP SEND_TO_TXD CLR TI RET SEND_TO_TXD: CLR TI MOV SBUF,@R0 INC R0 JNB TI,$ CJNE @R0,#']',SEND_TO_TXD RET
CSEG AT 0100H LABEL: DB "TESTING TESTING 1 2 3]" TRANS: MOV DPTR,#LABEL ;load data pointer with LABEL's address MOV R0,#0 LJMP SEND_TO_TXD CLR TI RET SEND_TO_TXD: CLR TI MOV A,R0 MOVC A,@A+DPTR MOV SBUF,A INC R0 JNB TI,$ CJNE A,#']',SEND_TO_TXD RET
Hey Dan! Thanks for the great help! I've refered the instruction ( MOVC A,@A+DPTR )in the book by THOMAS W SCHULTZ and the book explains the above instruction is to move contents pointed by sum of DPTR and ACC into ACC. Am i right to say that by using the above instruction, i am actually adding 00H (for the first loop) to the address pointed to by DPTR, and then shift the contents to the accumulator?
Just a quick question. Previously i've done the following.
CSEG AT 00F0H LABEL: DB "TESTING TESTING 1 2 3]" TRANS: MOV DPTR,#LABEL ;load data pointer with LABEL's address MOV R0,DPL LJMP SEND_TO_TXD CLR TI RET SEND_TO_TXD: CLR TI MOV SBUF,@R0 INC R0 JNB TI,$ CJNE @R0,#']',SEND_TO_TXD RET
"Am i right to say that by using the above instruction, i am actually adding 00H (for the first loop) to the address pointed to by DPTR, and then shift the contents to the accumulator?" Yes, DPTR remains constant while R0 (thus ACC) increments as an offset from the constant address contained in DPTR. Without varying DPTR, the routine can only support strings as long as 256 bytes (which is probably reasonable). Instead, by always using a zero offset and incrementing DPTR, one can avoid the 256-byte limitation:
CSEG AT 0100H LABEL: DB "TESTING TESTING 1 2 3]" TRANS: MOV DPTR,#LABEL ;load data pointer with LABEL's address LJMP SEND_TO_TXD CLR TI RET SEND_TO_TXD: CLR TI CLR A MOVC A,@A+DPTR MOV SBUF,A INC DPTR JNB TI,$ CJNE A,#']',SEND_TO_TXD RET
"Can characters defined under code segment simply be displayed like this?" No, the only (conventional) way to access code memory is using MOVC. "Is certain part of the memory only meant for code, and certain part only meant for data?" Yes, @RO (and @R1) only access internal data memory. MOVX is used to access memory classified as "external" data memory.
Hey Dan!! I'm really thankful for your help and the information you have provided. What you have said is very useful to me. I can't wait to return to my lab tomorrow to do some testings... Once again, appreciate your help! =) Have a great day!
"I'm really thankful for your help and the information you have provided. What you have said is very useful to me." You're welcome. If you haven't read it already, the following document describes the various 8051 memory spaces and the instructions used to access them. http://www.semiconductors.philips.com/acrobat_download/various/80C51_FAM_ARCH_1.pdf