'Using a Register in a DB

Hi I am trying to print text in a LCD using Assembly code (KEIL), I was using db 'text here' to do this. Now I need to transform a byte in a register to the ASCII, is there a way?

In this code I am trying to transform the registers between location 20 and 29 to a LCD screen but using db and the indirect register @r0 does not transform the byte to ASCII code

    MOV 20H , #3AH   
        MOV 21H , #10H 
        MOV 22H , #08H 
        MOV 23H , #92H 
        MOV 24H , #0A4H 
        MOV 25H , #34H 
        MOV 26H , #55H 
        MOV 27H , #01H 
        MOV 28H , #0C4H 
        MOV 29H , #0B1H
Disp:   
MOV R0, #20H

MOV A, #38H     // use 2 lines and 5*7 
ACALL com    
MOV A, #0EH   //cursor blinking off 
ACALL com    
MOV A, #80H   // force cursor to first line 
ACALL com  
MOV A, #01H     //clr screen
ACALL com   
Muestreo: ACALL DEL_ROUTINE
MOV A, #01H     //clr screen
ACALL com 

MOV DPTR ,#STR
MOV A,#00H  
MOVC A,@A+DPTR    
ACALL L_D    
INC DPTR   

MOV A,#00H   
MOVC A,@A+DPTR    
ACALL L_D    
INC DPTR   
INC R0
JMP Muestreo 
  

com: ACALL DEL_ROUTINE  
MOV P1, A   
CLR P2.1   
SETB P2.2
CLR P2.2
RET    

L_D: ACALL DEL_ROUTINE  
MOV P1, A      
SETB P2.1     
SETB P2.2     
CLR P2.2     
RET       



DEL_ROUTINE: MOV R1, #0FFH  
L1: MOV R2, #0FFH   
L2: DJNZ R2, L2    
DJNZ R1, L1     
RET

STR: 
    DB @R0

END


Solution 1:[1]

If you want display some ASCII string from program memory use code like this

            MOV DPTR ,#STR ;set pointer to string
nextChar:
            MOV A,#00H  
            MOVC A,@A+DPTR ;get char from string
            jz endDisp     ;if string terminator, stop ouput
            ACALL L_D      ;disp char
            INC DPTR       ;move pointer to next char
            JMP nextChar   ;loop for all chars
endDisp:    jmp endDisp
STR:        DB "Hello",0

If you want display internal SRAM you need provide more info about data formating. It is unclear from you code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Plesník