Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a ASSEMBLY language code(not C code) which accepts an input string of 9 characters from the keypad and displaying them on the first row

Write a ASSEMBLY language code(not C code) which accepts an input string of 9 characters from the keypad and displaying them on the first row of the LCD screen according to the following table:

Input 0-9 A B C D E F
Displayed 0-9 s q r t ( )

Below are the codes of lcdTest.asm and keypad.asm which are already given.

keypad.asm

ORG 0

acall CONFIGURE_LCD

KEYBOARD_LOOP: acall KEYBOARD ;now, A has the key pressed acall SEND_DATA sjmp KEYBOARD_LOOP

CONFIGURE_LCD: ;THIS SUBROUTINE SENDS THE INITIALIZATION COMMANDS TO THE LCD mov a,#38H ;TWO LINES, 5X7 MATRIX acall SEND_COMMAND mov a,#0FH ;DISPLAY ON, CURSOR BLINKING acall SEND_COMMAND mov a,#06H ;INCREMENT CURSOR (SHIFT CURSOR TO RIGHT) acall SEND_COMMAND mov a,#01H ;CLEAR DISPLAY SCREEN acall SEND_COMMAND mov a,#80H ;FORCE CURSOR TO BEGINNING OF THE FIRST LINE acall SEND_COMMAND ret

SEND_COMMAND: mov p1,a ;THE COMMAND IS STORED IN A, SEND IT TO LCD clr p3.5 ;RS=0 BEFORE SENDING COMMAND clr p3.6 ;R/W=0 TO WRITE setb p3.7 ;SEND A HIGH TO LOW SIGNAL TO ENABLE PIN acall DELAY clr p3.7 ret

SEND_DATA: mov p1,a ;SEND THE DATA STORED IN A TO LCD setb p3.5 ;RS=1 BEFORE SENDING DATA clr p3.6 ;R/W=0 TO WRITE setb p3.7 ;SEND A HIGH TO LOW SIGNAL TO ENABLE PIN acall DELAY clr p3.7 ret

DELAY: push 0 push 1 mov r0,#50 DELAY_OUTER_LOOP: mov r1,#255 djnz r1,$ djnz r0,DELAY_OUTER_LOOP pop 1 pop 0 ret

KEYBOARD: ;takes the key pressed from the keyboard and puts it to A mov P0, #0ffh ;makes P0 input K1: mov P2, #0 ;ground all rows mov A, P0 anl A, #00001111B cjne A, #00001111B, K1 K2: acall DELAY mov A, P0 anl A, #00001111B cjne A, #00001111B, KB_OVER sjmp K2 KB_OVER: acall DELAY mov A, P0 anl A, #00001111B cjne A, #00001111B, KB_OVER1 sjmp K2 KB_OVER1: mov P2, #11111110B mov A, P0 anl A, #00001111B cjne A, #00001111B, ROW_0 mov P2, #11111101B mov A, P0 anl A, #00001111B cjne A, #00001111B, ROW_1 mov P2, #11111011B mov A, P0 anl A, #00001111B cjne A, #00001111B, ROW_2 mov P2, #11110111B mov A, P0 anl A, #00001111B cjne A, #00001111B, ROW_3 ljmp K2

ROW_0: mov DPTR, #KCODE0 sjmp KB_FIND ROW_1: mov DPTR, #KCODE1 sjmp KB_FIND ROW_2: mov DPTR, #KCODE2 sjmp KB_FIND ROW_3: mov DPTR, #KCODE3 KB_FIND: rrc A jnc KB_MATCH inc DPTR sjmp KB_FIND KB_MATCH: clr A movc A, @A+DPTR; get ASCII code from the table ret

;ASCII look-up table KCODE0: DB '1', '2', '3', 'A' KCODE1: DB '4', '5', '6', 'B' KCODE2: DB '7', '8', '9', 'C' KCODE3: DB '*', '0', '#', 'D'

END

lcdTest.asm

ORG 0

acall CONFIGURE_LCD clr a mov dptr,#MYSTRING

DATA_LOOP: movc a,@a+dptr jz DATA_FINISHED acall SEND_DATA clr a inc dptr sjmp DATA_LOOP

DATA_FINISHED: sjmp $

CONFIGURE_LCD: ;THIS SUBROUTINE SENDS THE INITIALIZATION COMMANDS TO THE LCD mov a,#38H ;TWO LINES, 5X7 MATRIX acall SEND_COMMAND mov a,#0FH ;DISPLAY ON, CURSOR BLINKING acall SEND_COMMAND mov a,#06H ;INCREMENT CURSOR (SHIFT CURSOR TO RIGHT) acall SEND_COMMAND mov a,#01H ;CLEAR DISPLAY SCREEN acall SEND_COMMAND mov a,#80H ;FORCE CURSOR TO BEGINNING OF THE FIRST LINE acall SEND_COMMAND ret

;P1.0-P1.7 ARE CONNECTED TO LCD DATA PINS D0-D7 ;P3.5 IS CONNECTED TO RS ;P3.6 IS CONNECTED TO R/W ;P3.7 IS CONNECTED TO E

SEND_COMMAND: ;THIS SUBROUTINE IS FOR SENDING THE COMMANDS TO LCD mov p1,a ;THE COMMAND IS STORED IN A, SEND IT TO LCD clr p3.5 ;RS=0 BEFORE SENDING COMMAND clr p3.6 ;R/W=0 TO WRITE setb p3.7 ;SEND A HIGH TO LOW SIGNAL TO ENABLE PIN acall DELAY clr p3.7 ret

SEND_DATA: ;THIS SUBROUTINE IS FOR SENDING THE DATA TO BE DISPLAYED mov p1,a ;SEND THE DATA STORED IN A TO LCD setb p3.5 ;RS=1 BEFORE SENDING DATA clr p3.6 ;R/W=0 TO WRITE setb p3.7 ;SEND A HIGH TO LOW SIGNAL TO ENABLE PIN acall DELAY clr p3.7 ret

DELAY: ;A SHORT DELAY SUBROUTINE push 0 push 1 mov r0,#50 DELAY_OUTER_LOOP: mov r1,#255 djnz r1,$ djnz r0,DELAY_OUTER_LOOP pop 1 pop 0 ret

MYSTRING: DB 'LCD IS OK!',0

END

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago

Question

Know how to use reservations systems to inventory demand.

Answered: 1 week ago