; interfacing lcd 16×2 in 4-bit mode.
; port0 to higher nibble data pins of lcd
; crystal 3.579545 mhz
; at89c51
;p2.0 to rs pin
;p2.1 to enable pin 

    .ORG    0000H
    SJMP    MAIN
MAIN:
    MOV SP, #60H    ;stack pointer
    ACALL   LCD_INIT    ;initialize lcd
    MOV DPTR, #MESSAGE1
    CALL    LCD_STRING  ;display message on lcd
    CALL    NEXT_LINE   ;place cursor to;second line
    MOV DPTR, #MESSAGE2
    CALL    LCD_STRING  ;display message on lcd
HERE:   AJMP    HERE

LCD_INIT:           ;initialize lcd in 4-bit mode
    ANL P0, #0F0H
    CALL    LOOP
    MOV DPTR, #LCDCODE
    MOV A, #0H
    MOV R6, #0H
    MOV R7, #0H
    CLR P2.0        ;rs command
NEXT:               ;8-bit code is split into two 4-bit nibbles.
    INC R6
    MOVC    A, @A+DPTR
    MOV R7, A
    ANL A, #0F0H
    SWAP    A
    ANL P0, #0F0H
    ORL P0, A
    ACALL   ENABLE      ;pulse e sending first nibble
    MOV A, R7
    ANL A, #0FH
    ANL P0, #0F0H
    ORL P0, A
    ACALL   ENABLE      ;pulse e sending second nibble
    MOV A, R6
    CJNE    R6, #09H, NEXT
    RET

LCD_STRING:
    MOV P0, #00H
    SETB    P2.0        ;rs data
    MOV A, #00H
    MOV R6, #00H
NC:             ;checks the end of message string
    MOVC    A, @A+DPTR
    CJNE    A, #2FH, NC1
    RET
NC1:
    LCALL   LCD_WRITE
    INC R6
    MOV A, R6
    AJMP    NC

LCD_WRITE:
    SETB    P2.0        ;rs data
    CALL    LO
    RET

NEXT_LINE:
    MOV P0, #00H
    CLR P2.0        ;rs command
    MOV A, #0C0H
    CALL    LO
    RET

LCD_CLEAR:          ;this subroutine is used to clear lcd
    CALL    DELAYL
    ANL P0, #00H
    MOV A, #01H
    CLR P2.0        ; rs command

LO:             ;8-bit code is split into two 4-bit nibbles.
    MOV R7, A
    ANL A, #0F0H
    SWAP    A
    ANL P0, #0F0H
    ORL P0, A
    CALL    ENABLE
    MOV A, R7
    ANL A, #0FH
    ANL P0, #0F0H
    ORL P0, A
    CALL    ENABLE
    RET

ENABLE:             ;give high-to-low pulse at enable pin
    SETB    P2.1
    CALL    DELAYL
    CLR P2.1
    CALL    DELAYL
    RET

;with respect to crystal frequency 3.579 mhz
DELAYL:             ; 5ms delay
    SETB    PSW.4       ; select bank 2
    MOV R7, #25
HDH:
    MOV R6, #60
    DJNZ    R6, $
    DJNZ    R7, HDH
    CLR PSW.4       ;default bank
    RET

LOOP:               ;1 sec delay
    MOV R7, #100
LOOP1:
    CALL    DELAYL
    CALL    DELAYL
    DJNZ    R7, LOOP1
    RET

;lcd initializing code (do not disturb this)

LCDCODE:
    DB  02H
    DB  02H
    DB  02H
    DB  28H
    DB  28H
    DB  28H
    DB  0CH
    DB  06H
    DB  01H

;data to be displayed
;maximum message length = 16 characters.
;to notify end of message place ‘/’ at the end. 

MESSAGE1:   DB  ' Debashish /'  ;change message1

MESSAGE2:   DB  ' Mohapatra /'  ;change message2

END

Download Code and Model Here.