0% found this document useful (0 votes)
56 views4 pages

LCD 8051 Interfacing With Keypad

The document contains 5 questions and answers related to 8051 microcontroller programming. Question 1 asks to add two multi-byte hexadecimal numbers and store the result in RAM locations 40H-44H. Question 2 asks to add two single byte hexadecimal numbers and store the result and number of carries. Question 3 asks about stack pointer value and RAM addresses. Question 4 asks to transfer the string "VIT UNIVERSITY" from location 120H to 40H. Question 5 asks to add two single-byte BCD numbers and store the result and number of carries.

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views4 pages

LCD 8051 Interfacing With Keypad

The document contains 5 questions and answers related to 8051 microcontroller programming. Question 1 asks to add two multi-byte hexadecimal numbers and store the result in RAM locations 40H-44H. Question 2 asks to add two single byte hexadecimal numbers and store the result and number of carries. Question 3 asks about stack pointer value and RAM addresses. Question 4 asks to transfer the string "VIT UNIVERSITY" from location 120H to 40H. Question 5 asks to add two single-byte BCD numbers and store the result and number of carries.

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

TASK 1

Submitted by

RAHUL TRIPATHY (15BEC0253)

Q1. Add 2 multibyte HEX Numbers

Ans.
Code:

;WAP to add multi-byte BCD together and store the result in RAM locations 40H-44H
/* data 1: ORG 120H
54H, 76H,65H,98H
data 2: ORG 150H
93H,56H,77H,38H
*/
ORG 120H
DB 54H, 76H,65H,98H
ORG 150H
DB 93H,56H,77H,38H
ORG 0H
MOV DPTR,#120H
MOV R0, #40H
MOV R6,#4
LOOP: ; MOVING FIRST NUMBER
CLR A
MOVC A,@A+DPTR
MOV @R0,A
INC DPTR
INC R0
DJNZ R6,LOOP
CLR A
MOV R6,#0H
MOV R0,#0H
MOV DPTR,#150H
MOV R0, #44H
MOV R6,#4
LOOP2: ; MOVING SECOND NUMBER
CLR A
MOVC A,@A+DPTR
MOV @R0,A
INC DPTR
INC R0
DJNZ R6,LOOP2

;ADD
MOV R6,#4
MOV R3,#0
MOV R0,#40H
MOV R1,#44H
ADDLOOP:
MOV A,@R0
ADD A,@R1
ADD A,R3
JNC NOCARRY
MOV R3,#1H
NOCARRY:
MOV @R0,A
INC R0
INC R1

DJNZ R6,ADDLOOP

HERE: SJMP HERE


END

OUTPUT: D:0X40: E7 CC DC D0

Q2. Adding 2 Single byte HEX Numbers

ORG 120H
DB 0ABH,0CH,128,78H,23H ;create database of hex numbers

ORG 0H
MOV R7,#00H
MOV DPTR,#120H ;dptr points to first value of database
MOV R4,#05
LOOP:CLR A
MOVC A,@A+DPTR ;move value pointed by dptr to acc.
ADDC A,R7 ;add acc. Aand R7 with carry
JNC L1
INC R6
L1:MOV R7,A
INC DPTR
DJNZ R4,LOOP
MOV 40H,R7 ;store final answer from 40H address onwards
MOV 41H,R6 ;store number of carries generated
HERE:SJMP HERE
END

Q3. Stack Pointer Value & RAM Addresses

ORG 0H
SETB PSW.3 ;Bank 1 selected from RAM
MOV R6,#25H
MOV R7,#12H
SETB PSW.4 ;Bank 3 selected from RAM
MOV R5,#0F3H
MOV R3,#0DEH
CLR PSW.3 ;Bank 2 selected from RAM
MOV R2,#0FFH
PUSH 11H ;push 11 to stack
PUSH 0FH ;push 0F to stack
PUSH 0EH ;push 0E to stack
PUSH 0DH ;push 0D to stack
PUSH 1DH ;push 1D to stack
POP 0DH ;push 0D to stack
POP 0FH pop 0F from stack
POP 11H
POP 17H
END

Q4. Transfer VIT UNIVERSITY from 120H to 40H

ORG 120H
DB "VIT UNIVERSITY" ;create database

ORG 0H
MOV R5,#14
MOV DPTR,#120H ;dptr points to V
MOV R0,#40H
LOOP: CLR A
MOVC A,@A+DPTR ;move value from ROM to acc.
MOV @R0,A ;indirect addressing mode
INC DPTR
INC R0
DJNZ R5,LOOP ;LOOP runs for 14 times

MOV DPTR,#1020H ;dptr points to external RAM address


MOV R0,#40H
MOV R5,#14
L1: MOV A,@R0 ;value stored in indirect address moved to acc.
MOVX @DPTR,A ;value in acc. Moves to external RAM
INC R0
INC DPTR
DJNZ R6,L1
HERE: SJMP HERE
END

Q5. Adding two single-byte BCD numbers

ORG 120H
DB 96,54,128,78,23 ;create database of hex numbers

ORG 0H
MOV R7,#00H
MOV DPTR,#120H ;dptr points to first value of database
MOV R4,#05
LOOP:CLR A
MOVC A,@A+DPTR ;move value pointed by dptr to acc.
ADDC A,R7 ;add acc. Aand R7 with carry
JNC L1
INC R6
L1:MOV R7,A
INC DPTR
DJNZ R4,LOOP
MOV 40H,R7 ;store final answer from 40H address onwards
MOV 41H,R6 ;store number of carries generated
HERE:SJMP HERE
END

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy