| ??? 08/19/04 05:10 Read: times |
#76142 - DPTR/Lk UpTbl Difficulty: Advice Please? |
Hi everybody! In my attempt to 'modularize' and reduce my ASM LCD code, I have been plagued by a what seems like a stinker of a problem...
Problem: Look-up-table code fails when DPTR uses literal .ORG location values, succeeds when using only #"LABEL" addressing. I think I am missing something elementary, but I could not find resolution in old forum postings...your advice is greatly appreciated! This code works:
;-----------Subroutine: DSPSTRING---------------------
DSPSTRING:
push ACC ;Saving reg. contents for
push DPL ;safe keeping
push DPH ;
mov DPTR,#STRING1 ;***Problem area???
DSP1: ;Section 1: get the first string character
clr A
movc a,@a+DPTR ;Get char. from ROM code space
inc DPTR ;Use INC DPTR to address next string char.
cjne a,#00h,DSP2;A = 00h? (End of string [NULL]?) If so,
ajmp DSP3 ;then don't jump; else, go to DSP3 to RETurn
DSP2:
push DPL ;Save DPTR contents before LCD output subr.
push DPH ;
lcall CHAROUT ;call LCD data subroutine
pop DPH ;restore DPTR
pop DPL ;
ajmp DSP1 ;Loop & get next string char
DSP3:
pop DPH ;Restore entrance val of DPTR
pop DPL ;
pop ACC ;Restore entrance value of A
RET ;Exit subroutine
;------DATA TABLE--------------------------------------
STRING1: ;first test string
.db "Hola Grace"
.db 00h
STRING2: ;second test string
.db "Te amo Peru"
.db 00h
However, if I change MOV DPTR,#STRING1 in "DSPSTRING" section to mov DPL,#00h and mov DPH,#01h along with STRING1 to .ORG 0100h, it fails (no char to LCD [blank], as if it string was never found....but simulates o.k. P.S.: the table is definitely located at my .ORG no problem. I don't understand why I can't use literal table addresses here. I (wish) to use predefined .ORG table location values instead of labels with DPTR routine! Any advice? Thanks so much, Marty :) |
| Topic | Author | Date |
| DPTR/Lk UpTbl Difficulty: Advice Please? | 01/01/70 00:00 | |
| RE: DPTR/Lk UpTbl Difficulty: Advice Ple | 01/01/70 00:00 | |
| Tried those suggestions... | 01/01/70 00:00 | |
| RE: Tried those suggestions... | 01/01/70 00:00 | |
| You missed one! | 01/01/70 00:00 | |
| Reply: You missed one! Andy/Bartosz | 01/01/70 00:00 | |
| RE: DPTR/Lk UpTbl Difficulty: Advice Please? | 01/01/70 00:00 | |
| RE: DPTR/Lk UpTbl Difficulty: Advice Please? | 01/01/70 00:00 | |
| Check the generated code. | 01/01/70 00:00 | |
| RE: DPTR/Lk UpTbl Difficulty: Advice Please? | 01/01/70 00:00 | |
| RE: DPTR/Lk UpTbl Difficulty: Advice Please? | 01/01/70 00:00 | |
<-- Problem Resolved! --> | 01/01/70 00:00 |



