Org 0000H

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

ORG 0000H

lcd equ P3 ;lcd connected to port p3

EN equ P2.7 ;enable connected to port p2.7

RW equ P2.6 ;read write connected to port p2.6

rs equ P2.5 ;register select connected to port p2.5

mov a,#38h ;to initialize lcd as 8 bit data length

acall command ;call command subroutine

mov a,#0Eh ;to turn on display, cursor blinking

acall command ;call command subroutine

mov a,#01h ;to clear display

acall command ;call command subroutine

mov a,#06h ;to shift cursor to left for next character

acall command ;call command subroutine

mov a,#80h ;to display content from fifth position on line 1

acall command ;call command subroutine

mov a,#'S' ;load ASCII code of S into accumulator

acall display ;call display subroutine

mov a,#'A' ;load ASCII code of A into accumulator

acall display ;call display subroutine

mov a,#'M' ;load ASCII code of M into accumulator

acall display ;call display subroutine

mov a,#'I' ;load ASCII code of I into accumulator

acall display ;call display subroutine

mov a,#'K' ;load ASCII code of K into accumulator

acall display ;call display subroutine

mov a,#'S' ;load ASCII code of S into accumulator

acall display ;call display subroutine

mov a,#'H' ;load ASCII code of H into accumulator

acall display ;call display subroutine

mov a,#'A' ;load ASCII code of A into accumulator


acall display ;call display subroutine

mov a,#' '

acall display ;call display subroutine

mov a,#'W' ;load ASCII code of W into accumulator

acall display ;call display subroutine

mov a,#'A' ;load ASCII code of A into accumulator

acall display ;call display subroutine

mov a,#'G' ;load ASCII code of G into accumulator

acall display ;call display subroutine

mov a,#'H' ;load ASCII code of H into accumulator

acall display ;call display subroutine

mov a,#0C0H ;to display content from fifth position on line 2

acall command ;call command subroutine

mov a,#'R' ;load ASCII code of R into accumulator

acall display ;call display subroutine

mov a,#'O' ;load ASCII code of O into accumulator

acall display ;call display subroutine

mov a,#'L' ;load ASCII code of L into accumulator

acall display ;call display subroutine

mov a,#'L' ;load ASCII code of L into accumulator

acall display ;call display subroutine

mov a,#' '

acall display ;call display subroutine

mov a,#'N' ;load ASCII code of N into accumulator

acall display ;call display subroutine

mov a,#'O' ;load ASCII code of O into accumulator

acall display ;call display subroutine

mov a,#'.'

acall display ;call display subroutine

acall delay

BACK:MOV P1,#11111111B // loads P1 with all 1's

CLR P1.0 // makes row 1 low

JB P1.4,NEXT1 // checks whether column 1 is low and jumps to NEXT1 if not low
MOV a,#00h // loads a with 00H if column is low (that means key 1 is pressed)

acall display// calls DISPLAY subroutine

NEXT1:

JB P1.5,NEXT2

MOV A,#01h

acall display

NEXT2:

JB P1.6,NEXT3

MOV A,#02h

acall display

NEXT3:

JB P1.7,NEXT4

MOV A,#03h

acall display

NEXT4:

SETB P1.0

CLR P1.1

JB P1.4,NEXT5

MOV A,#04h

acall display

NEXT5:

JB P1.5,NEXT6

MOV A,#05h

acall display

NEXT6:

JB P1.6,NEXT7
MOV A,#06h

acall display

NEXT7:

JB P1.7,NEXT8

MOV A,#07h

acall display

NEXT8:

SETB P1.1

CLR P1.2

JB P1.4,NEXT9

MOV A,#08h

acall display

NEXT9:

JB P1.5,NEXT10

MOV A,#09h

acall display

NEXT10:

JB P1.6,NEXT11

MOV A,#0AH

acall display

NEXT11:

JB P1.7,NEXT12

MOV A,#0BH

acall display

NEXT12:

SETB P1.2
CLR P1.3

JB P1.4,NEXT13

MOV A,#0CH

acall display

NEXT13:

JB P1.5,NEXT14

MOV A,#0DH

acall display

NEXT14:

JB P1.6,NEXT15

MOV A,#0EH

acall display

NEXT15:

JB P1.7,BACK

MOV A,#0FH

acall display

LJMP BACK

here:sjmp here

command: ;command subroutine

acall delay;call delay subroutine

mov lcd,a ;send command to lcd

clr RS ;rs=0 for command

clr RW ;rw=0 to write command

setb EN ;sending a high to low pulse to enable lcd

acall delay ;call delay subroutine

clr EN
ret

display: ;display subroutine

acall delay;call delay subroutine

mov lcd,a ;send data to lcd

setb RS ;rs=0 for command

clr RW ;rw=0 to write data

setb EN ;sending a high to low pulse to enable lcd

acall delay ;call delay subroutine

clr EN

ret

delay: ;delay subroutine

mov r3,#200

l5: mov r4,#200

l6: djnz r4,l6

djnz r3,l5

ret ;ret

END

You might also like