You are on page 1of 22

NAME : ashish KUMAR

REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

DIGITAL ASSIGNMENT 05

TITLE : LCD & ARM PROGRAMMING

NAME : ashish KUMAR


REGISTRATION NO. : 21BEC2017
SLOT : L33+L34
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

LCD PROGRAMMING

QUESTION: Connect the LCD to your 8051 Kit. Then write and run a program to
display your name on line 1 of the LCD (first name followed by last name with a space in
between).
Note: If you are not monitoring the busy flag of the LCD, put a few milliseconds delay in
your program.

;P1.0-P1.7 are connected to LCD data pins D0-D7


;P2.0 is connected to RS pin of LCD
;P2.1 is connected to R/W pin of LCD
;P2.2 is connected to E pin of LCD

LCD CONNECTION DIAGRAM:


NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

PROGRAM:
ORG 0000H
MOV A,#38H
ACALL CMNWRT
ACALL DELAY
MOV A,#0EH
ACALL CMNWRT
ACALL DELAY
MOV A,#01H
ACALL CMNWRT
ACALL DELAY
MOV A,#06H
ACALL CMNWRT
ACALL DELAY
MOV A,#80H
ACALL CMNWRT
ACALL DELAY
MOV A,#'V'
ACALL DATWRT
ACALL DELAY
MOV A,#'I'
ACALL DATWRT
ACALL DELAY
MOV A,#'T'
ACALL DATWRT
ACALL DELAY
AGAIN: SJMP AGAIN
CMNWRT:
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS


MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
CLR P2.2
RET
DATWRT:
MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
CLR P2.2
RET
DELAY: MOV R3,#0FFH
MOV R4,#0FFH
MOV R5,#55H
HERE: DJNZ R5,HERE
HERE1: DJNZ R4, HERE1
HERE2: DJNZ R3,HERE2
RET
END
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

SIMULATION:
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

OBSERVATION:
We observed here that when we pressed the reset button on the LCD processor it started
displaying VIT one by one character on the LCD screen.
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

QUESTION: Connect the LCD to your 8051 Kit. Then write and run a program to
display “VIT UNIVERSITY” on 2 line of the LCD.

LCD CONNECTION DIAGRAM:

PROGRAM:
ORG 200H
DB 'VIT'
CHECK: SJMP CHECK
ORG 250H
DB 'UNIVERSITY'
CHECK2: SJMP CHECK2
ORG 0H
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS


MOV DPTR,#200H
MOV R1,#03H
MOV R2,#0AH
MOV A,#38H
ACALL CMDWRT
ACALL DELAY
MOV A,#0EH
ACALL CMDWRT
ACALL DELAY
MOV A,#01H
ACALL CMDWRT
ACALL DELAY
MOV A,#06H
ACALL CMDWRT
ACALL DELAY
MOV A,#084H
ACALL CMDWRT
ACALL DELAY
LOOP: CLR A
MOVC A,@A+DPTR
ACALL DATAWRT
INC DPTR
ACALL DELAY
DJNZ R1,LOOP
MOV DPTR,#250H
MOV A,#0C4H
ACALL CMDWRT
ACALL DELAY
LOOP2: CLR A
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS


MOVC A,@A+DPTR
ACALL DATAWRT
INC DPTR
ACALL DELAY
DJNZ R2,LOOP2
AGAIN: SJMP AGAIN
CMDWRT:MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
DATAWRT:MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
DELAY:MOV R3,#255
HERE2: MOV R4,#255
HERE:DJNZ R4,HERE
DJNZ R3,HERE2
RET
END
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

SIMULATION:
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

OBSERVATION:
We observed here that when we pressed the reset button on the LCD processor started
displaying VIT in one line and UNIVERSITY in next line, one by one character on the LCD
screen display using the DPTR command.
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

ADVANCED RISC MACHINE [ARM]

QUESTION_01: Add the contents of Registers R1,R2 and save the result in to R3.Use
Step execution in keil, write down the contents of various flags of ARM7

PROGRAM:
AREA PROG_2_1, CODE, READONLY
ENTRY
MOV R1, #0x25 ;R1 = 0x25
MOV R2, #0x34 ;R2 = 0x34
ADD R3, R2,R1 ;R3 = R2 + R1
HERE B HERE ;stay here forever
END

SIMULATION:
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

OBSERVATION:
We observed here that we can add two values using ADD command by first storing the two
values in R1 and R2 registers respectively and then adding them and storing the result in R3
register.
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

QUESTION_02: Perform Multiplication operations in ARM7.

PROGRAM:
AREA EXP2, CODE, READONLY
ENTRY
START MOV R0,#0XFFFFFFFF
MOV R1,#0X80000000
MULS R2,R0,R1
END

SIMULATION:

OBSERVATIONS:
We observed here that we multiplied two values using MULS command and storing the
resulted value in R2 register.
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

QUESTION_03: Let the register content of r5 and r7 are 5 and 8 respectively. Without
using MUL instruction make r5 content as 14h(20d).

PROGRAM:
AREA EXP3, CODE, READONLY
ENTRY
START MOV R5,#5
MOV R7,#8
MOV R7,R5,LSL#2
END

SIMULATION:

OBSERVATIONS:
We observed here that to make the value of R5 as 14H from 5D we used the LSL instruction
i.e logically shift left two time because 5D=0101B after 1 left shift it becomes 10D=01010B
and after 2nd left shift it becomes 20D=010100H.
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

QUESTION_04: Load R1 register with F631024C and R0 register with 17539ABD.


Swap the contents using a logic gate function.

PROGRAM:
AREA EXP3, CODE, READONLY
ENTRY
START LDR R1,=0xF631024C
LDR R0,=0x17539ABD
EOR R0,R0,R1
EOR R1,R0,R1
EOR R0,R0,R1
END

SIMULATION:
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

OBSERVATIONS:
We observed here that when we perform XOR operation on two values which are stored in
R0 and R1 respectively we get a new value that is stored in one of the register(here R0) and
then again we perform the XOR operation of the value stored with the other value then we
get the First value which we stored in the other register(here R1).Lastly we again performed
XOR operation to get the other value which is then stored in the other register(here R0) and
hence swapping the two values of both the registers.
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

QUESTION_05: What is the inference of the following code? Execute and Observe.

PROGRAM:
AREA EXP3, CODE, READONLY
ENTRY
START MOV R1,#0x77
MOV R0,#0
RSB R0,R1,#2
END

SIMULATION:

OBSERVATIONS:
We observed here that using rsb command we subtracted the value of R1 register i.e.(77H)
from 2 and stored the result in R0 register that means R0=77h-2d.
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

QUESTION_06: What is the inference of the following code? Execute and Observe.

PROGRAM:
AREA EXP10, CODE, READONLY
ENTRY
START MOV R0,#5
MOV R3,R0
MOV R1,#1
LOOP
MUL R2,R0,R1
MOV R0,R2
ADD R1,#1
CMP R1,R3
BLT LOOP
MOV R5,R0
HLT
B HLT
END
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

SIMULATION:

OBSERVATIONS:
We observed here that the factorial of the integer 5 is computed using this code, and the result
is stored in register R5.R0 is initialised to 5, R3 to 5, and R1 to 1, then it enters a loop where
each iteration multiplies R0 by R1 and increases R1 by 1. The cycle repeats until R1 exceeds
R3 (where it is 5). The factorial of 5, which is kept in R5, is the ultimate value of R0.The
programme then goes into an infinite loop (HLT followed by B HLT) and stops working.
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

QUESTION_07: What is the inference of the following code? Execute and Observe.

PROGRAM:
AREA EXP4, CODE, READONLY
ENTRY
START MOV R0,#-4
LDR R2,=0X80000000
AND R3,R2,R0
CMP R3,R2
MVNEQ R1,R0
ADDEQ R1,#1
MOVNE R1,R0
HLT
B HLT
END

SIMULATION:
NAME : ashish KUMAR
REGISTRATION NO. : 21BEC2017

MICROPROCESSORS AND MICROCONTROLLERS

OBSERVATIONS:
In the above program, -4 is stored in RO, 80000000H is stored in R2, then AND operation is
performed with R2 and RO, the result is stored in R3. Now we compare the R3 value and the
R2 value, if they are equal we perform MVN operation (Bitwise NOT operation) else if they
are equal then we ADD 1 to R1. Finally if they are not equal we move RO to R1.

You might also like