You are on page 1of 62

EMBEDDED SYSTEMS

Laboratory
Record

ELECTRONICS AND COMMUNICATION ENGINEERING

SEMESTER: 7th

SESSION: 2015-2019

SCHOOL OF ENGINEERING

COCHIN UNIVERSITY OF SCIENCE AND TECHNOLOGY

KOCHI – 682022
EMBEDDED SYSTEMS (EC 15-17L1)

LABORATORY RECORD

Certified that this is the bonafide Record of the work done by


Name
ARUNKUMAR KR Reg. no. 13160016 of Semester 7th ECE-
A class in the Embedded System Laboratory during the year 2018.

Staff-in-Charge Head of the Department

Internal Examiner External Examiner


Arunkumar KR, Reg.no 13160016

DETAILS OF EXPERIMENTS

Exp No. DESCRIPTION OF EXPERIMENTS Page no.


I INTRODUCTION TO KIEL µVISION SOFTWARE 2
1 FAMILIARIZATION OF 8051 TRAINER KIT 3-9
2 ADDITION OF TWO NUMBERS IN 8051 TRAINER KIT 10-11
3 SUBTRACTION OF TWO NUMBERS IN 8051 TRAINER 12-13
KIT
4 MULTIPLICATION OF TWO NUMBERS IN 8051 14-15
TRAINER KIT
5 DIVISIONOF TWO NUMBERS IN 8051 TRAINER KIT 16-17
6 ADDITION OF ‘N’ NUMBERS IN 8051 TRAINER KIT 18-19
7 ADDITION OF TWO NUMBERS 20-21
8 ADDITION OF ‘N’ NUMBERS 22-23
9 ADDITION OF ‘N’ NUMBERS WITH CARRY 24-25
10 ADDITION OF TWO NUMBERS TO GIVEN PORTS 26-27
11 FACTORIAL OF A NUMBER 28-29
12 SMALLEST OF ‘N’ NUMBERS 30-31
13 BLINKING OF LED 32-34
14 TRAFFIC LIGHT CONTROL 35-41
15 VOWEL DISPLAY 42-46
16 00-99 COUNTER 47-51
17 DISPLAY NAME ON LCD DISPLAY 52-55
18 STEPPER MOTOR 56-57

KEIL

The Keil A51 Assembler is a macro assembler for the 8051 family of microcontrollers. It
supports all 8051 derivatives. It translates symbolic assembly language mnemonics into

1
Arunkumar KR, Reg.no 13160016

relocatable object code where the utmost speed, small code size, and hardware control are
critical. The macro facility speeds development and conserves maintenance time since common
sequences need only be developed once. The A51 assembler supports symbolic access to all
features of the 8051 architecture.

The A51 assembler translates assembler source files into a relocatable object modules. The
DEBUG directive adds full symbolic information to the object module and supports debugging with
the µVision Debugger or an in-circuit emulator. In addition to object files, the A51 assembler
generates list files which may optionally include symbol table and cross reference information.

2
Arunkumar KR, Reg.no 13160016

EXPERIMENT NO: 1

FAMILIARIZATION OF 8051 TRAINER KIT

The Intel MCS-51 is a Harvard Architecture, single chip microcontroller, which


was developed by Intel in 1980 for use in Embedded System. Intel’s original version was
popular in the 1980s and early 1990s. While Intel no longer manufactures the MCS-51,
binary compactable derivatives remain popular today.
The 8051 architecture provides many functions (CPU, RAM, ROM, I/O, and Interrupt
Logic) in a single package.
 8 bit ALU, Accumulators and 8 bit registers; hence it is an 8 bit microcontroller
 8 bit data bus – it can access 8 bit of data in one operation
16
 16 bit address bus – it can access 2 memory locations – 64KB (65536 locations)
each of RAM and ROM
 On chip RAM – 128 byte (Data Memory)
 On chip ROM – 4Kbyte (Program Memory)
 4 byte bi-directional I/O Port
 UART (Serial Port)
 2 16-bit counters/timer
 2 level interrupt priority
 Power saving mode
TRAINER KIT DETAILS:
MENU COMMANDS:
Command Explanation
A Assemble (in line assembler generated code corresponding to 8051 code
set)
B Block Move
D Disassemble
F Fill Data
G Go and execute
M Modify/View Memory
R Register view/Edit (Values of last break of single step)
S Single Step
T View/Edit Break point (Press enter to enable break point and backspace
to disable break point)

3
Arunkumar KR, Reg.no 13160016

Note:
 ‘Enter’ key to continue/accept the data for each command
 ‘ESC’ to exit from any command except execution (Press reset key to exit from
execution)
 ‘Back Space’ key to decrement address
MENU
On switching the unit after a scrolling display the menu appears as A,B,D,G,M,R,S and T

MENU ‘A’ : ASSEMBLE


User can enter the assembly language directly in to the kit. The assembler will assemble the
8051 instruction in machine code.When assembler option is chosen by pressing letter
‘A’, on IBM keyboard, the display will show like

ASSEMBLER
ENTER START ADDR….

Now the user can enter the starting address from where the assembling is
required Eg.:8000
After entering desired starting address press ‘ENTER’ key on the keyboard. The system
will show a text address screen. Enter a valid assembly instruction in this window. After
entry press ‘ENTER’ again
If a valid assembly code is entered, corresponding code in HEX will be displayed as

8000: 01 80 00

Then press ‘ENTER’ to continue assembling till end of the program.


Press <ESC> to exit from this menu and starting menu appears. The entered program
will be stored.

MENU ‘B’ : BLOCK COMMAND

BLOCK COMMAND
F,I,D,M
Select commands from above commands
F : Fill command
I : Insert
D : Delete
M : Move

4
Arunkumar KR, Reg.no 13160016

F : Fill Command
Fill command can be used to fill a specific data in specified locations

FILL DATA
ENTER STARTING ADDRESS:

Then enter the starting address of Fill and press ‘ENTER’. The screen will show:

FILL DATA
ENTER END ADDRESS

Enter end address and hit ENTER key. The screen will show:

DATA:00

Then enter the data to be filled and press ENTER. Data will be filled in specified
locations

I : Insert Command
Insert command helps to reserve some location for inserting bytes. It will move the next
bytes towards down and make free the locations to be inserted. User can insert data in
the locations using Memory edit command after insert command

INSERT
ENTER STARTING ADDRESS:

Enter starting address of program and then press ENTER

INSERT
ENTER END ADDRESS:

Enter End address of program and press ENTER

BYTE COUNT:

Enter Byte count to be inserted. The byte locations will be filled with zero. User can
insert data using memory edit command

5
Arunkumar KR, Reg.no 13160016

D : Delete Command
Delete command helps to delete some location for removing bytes. It will move the
next bytes upward.

DELETE
ENTER STARTING ADDRESS:

Enter starting address of the program, press ENTER

DELETE
ENTER END ADDRESS:

Enter End address of Program, press ENTER

BYTE COUNT:

Enter Byte count to be inserted.

M : Block Move Command


Block move command helps to move a block of memory RAM data to desired location.
This menu can be selected by pressing ‘B’ on the keyboard. When ‘B’ is pressed on the
keyboard, the display shows

BLOCK MOVE
ENTER STARTING ADDRESS:

Enter starting address of the data to be moves and press ENTER

BLOCK MOVE
ENTER END ADDRESS:

Enter End address of the data block and press ENTER. The display will show

BLOCK MOVE
DESTINATION ADDRESS:

Press valid destination address and press ‘ENTER’


Note: If starting address is greater than END address, an error message will be displayed.

6
Arunkumar KR, Reg.no 13160016

MENU ‘D’ : DISASSEMBLE COMMAND


The kit provides the facility to view the disassembled code of the program
From main menu select ‘D’(press) and the screen will show

DISASSEMBLE
ENTER STARTING ADDRESS:

Enter starting address of the code which is to be disassembled. The screen will show
the disassembly code with memory address like

8000: LJMP 8100

Press ENTER to continue disassembling and ESC for exiting from the menu

MENU ‘M’ : MODIFY/VIEW MEMORY COMMAND


In this mode, user can view the memory contents directly. Select his option by pressing
‘M’ key, then the screen will ask for starting address. The display will show

MODIFY MEMORY
8000: 00

Enter the new HEX value using 0-9 keys (of the cash register keys only) for number and
A-F keys for data keys. User need to enter only lower digit of the data for one digit
Press ENTER to increment/accept the data and ‘Backspace’ to decrement. User can view
the contents by pressing ‘ENTER’ up memory address. And ‘Backspace’ for down
memory address. Press ‘ESC’ to exit from this mode.
Note: The address to enter the data should be a valid user RAM address

MENU ‘R’ : REGISTER CONTENT VIEW/EDIT COMMAND


In this mode, register content of the last ‘break point’ or ‘step’ can be viewed/edited.
To achieve this, press ‘R’. The display shows the register content of the last break or step.
If there was no break or step, the register content is not valid.
After pressing ‘R’ key, the screen will show

A-00

Press ‘ENTER’ to increment registers to next and ‘Back Space’ to decrement

7
Arunkumar KR, Reg.no 13160016

User can enter to register content by using keyboard. The entry is similar to memory
modify command.

8
Arunkumar KR, Reg.no 13160016

Note: Modifying ‘SP’ will affect the program returns. So one has to be careful while
changing the value of ‘SP’
.
MENU ‘S’ : SINGLE STEP COMMAND
Single step command will help to troubleshoot the program. This can be selected by
pressing ‘S’ key. The system will ask for starting address

SINGLE STEP
STARTING ADDRESS:

Enter starting address and press ‘ENTER’.


Then the program will go to first step.
Press ‘ENTER’ key to go on stepping, ‘M’ to view menu commands and ‘ESC’ to exit
from stepping. Display will show the assemble code which is to be stepped next

MENU ‘T’ : BREAK POINT COMMAND


Break point can be set for checking the program in certain locations. User can
enter Break Point by selecting ‘T’ from main menu.
Press ‘T’ and then the display will show like

BREAK POINT:8000
ACALL 8100

Then select the address for which ‘Break Point’ is to be added. It will automatically
show the previous entered location.
Press ‘ENTER’ key to enable break point and ‘Back Space’ key to disable break point.
Then it will show ‘ENABLED’ or ‘DISABLED’ as selected.
Note: Break Point will come into effect when ‘GO’ command is selected from Main
menu.
If break is encountered in program, it will show ‘Break: 8000’, press ‘ENTER’ to view
the current code of breaking point and press ‘ENTER’ again to continue running the
program

MENU ‘G’ : GO / EXECUTE COMMAND


This command is used to perform execution of program. Select ‘G’ for execution. The
display will show

EXECUTE

9
Arunkumar KR, Reg.no 13160016

ENTER STARTING ADDR:

10
Arunkumar KR, Reg.no 13160016

Now enter the starting address of the program and press ‘ENTER’ again. The display will
show:

EXECUTING….

Until the monitor is reset by program of Break Point.


The selected program will be executed from the starting location and could be verified.
Press ‘RESET’ button on the kit to exit the program from execution.

11
Arunkumar KR, Reg.no 13160016

EXPERIMENT NO: 2

ADDITION OF TWO NUMBERS IN 8051 TRAINER KIT

AIM:
Write an assembly language program to add two digits numbers which are stored
in 8100, 8101 and store the result in 8102 and carry in 8103 using 8051 trainer kit.

ALGORITHM:
Step 01: Initially, store the two numbers in locations 8100 and 8101.
Step 02: Load the Data pointer with the address of the first number to be added.
Step 03: Copy the number to accumulator and then to register R0.
Step 04: Increment the data pointer.
Step 05: Copy the next number into the accumulator.
Step 06: Add the number in R0 to the number in accumulator.
Step 07: Increment the data pointer.
Step 08: Store the result in the memory location.
Step 09: Increment the data pointer.
Step 10: Clear the accumulator and copy the carry into the accumulator.
Step 11: Move the carry obtained into the memory location pointed by the data
pointer.

PROGRAM CODE:

Memory Mnemonics Instruction Comment


Location
8000 90,81,100 MOV DPTR,#8100 Set Source Address

8003 E0 MOVX A,@DPTR Get First Byte

8004 F8 MOV R0,A Store Temporarily


Increment Pointer To
8005 A3 INC DPTR Get Next Byte

8006 E0 MOVX A,@DPTR Get Next Byte

8007 28 ADD A,R0 Add


Increment Pointer To
8008 A3 INC DPTR Store Result

8009 F0 MOVX @DPTR,A Store LSB Of Result

12
Arunkumar KR, Reg.no 13160016

800A 74,00 MOV A,#00H Clear A

800C 34,00 ADDC A,#00H Add To Get Carry


Increment Pointer To
800E A3 INC DPTR Store MSB Of Result

800F F0 MOVX @DPTR,A Store MSB Of Result

8010 02,80,10 LJMP 8010 Wait Here

OUTPUT:

8100: 10 (Input 1)
8101: 10 (Input 2)
8102: 20 (Sum)
8103: 00 (Carry)

8100: 90 (Input 1)
8101: F0 (Input 2)
8102: 80 (Sum)
8103: 01 (Carry)

RESULT:
The program to add two numbers using trainer kit was successfully executed and
obtained the output.

13
Arunkumar KR, Reg.no 13160016

EXPERIMENT NO: 3

SUBTRACTION OF TWO NUMBERS IN


8051 TRAINER KIT

AIM:
Write an assembly language program to subtract two digits numbers which are stored
in 8100, 8101 and store the result in 8102 and borrow in 8103 using 8051 trainer kit.

ALGORITHM:
Step 01: Initially, store the two numbers in locations 8100 and 8101.
Step 02: Load the Data pointer with the address of the first number.
Step 03: Copy the number to accumulator and then to register R0.
Step 04: Increment the data pointer.
Step 05: Copy the next number into the accumulator.
Step 06: Clear the carry bit.
Step 07: Subtract the number in R0 from the number in accumulator.
Step 08: Increment the data pointer.
Step 09: Store the result in the memory location.
Step 10: Increment the data pointer.
Step 11: Clear the accumulator and copy the carry into the accumulator.
Step 12: Move the carry obtained into the memory location pointed by the data
pointer.

PROGRAM CODE:

Memory Mnemonics Instruction Comment


Location
8000 90,81,100 MOV DPTR,#8100 Set Source Address

8003 E0 MOVX A,@DPTR Get First Byte

8004 F8 MOV R0,A Store Temporarily

8005 A3 INC DPTR Increment Pointer

8006 E0 MOVX A,@DPTR Get Next Byte


8007 A3 INC DPTR Increment Pointer

14
Arunkumar KR, Reg.no 13160016

To Get Next Byte

8008 C3 CLR C Clear Carry

8009 98 SUBB A,R0 Subtract

800A F0 MOVX @DPTR,A Store LSB

800B A3 INC DPTR Increment Pointer

800C 74,00 MOV A,#00H Clear A

800E 34 ADDC A,#00H Add To Get Carry

800F F0 MOVX @DPTR,A Store MSB

8010 02,80,11 LJMP 8010 Wait Here

OUTPUT:

8100: 05 (Input 1)
8101: 03 (Input 2)
8102: FE (Difference)
8103: 01 (Borrow)

8100: E0 (Input 1)
8101: FF (Input 2)
8102: 1F (Difference)
8103: 00 (Borrow)

RESULT:
The program to subtract two numbers using trainer kit was successfully executed
and obtained the output.

15
Arunkumar KR, Reg.no 13160016

EXPERIMENT NO: 4

MULTIPLICATION OF TWO NUMBERS IN


8051 TRAINER KIT
AIM:
Write an assembly language program to multiply two digits numbers which are
stored in 8100, 8101 and store the result in 8102 and carry in 8103 using 8051 trainer kit.

ALGORITHM:
Step 01: Initially, store the two numbers in locations 8100 and 8101.
Step 02: Load the Data pointer with the address of the first number.
Step 03: Copy the number to accumulator and then to B. Increment the data pointer.
Step 04: Copy the next number into the accumulator.
Step 05: Multiply the numbers in A and B.
Step 06: Increment the data pointer.
Step 07: Store the result in A to the memory location.
Step 08: Increment the data pointer.
Step 09: Copy the content in B to the accumulator.
Step 10: Move it to the memory location pointed by the data pointer.

PROGRAM CODE:

Memory Mnemonics Instruction Comment


Location
8000 90,81,100 MOV DPTR,#8100 Set Source Address
8003 E0 MOVX A,@DPTR Get First Byte
8004 F5,F0 MOV F0,A Store Temporarily
8006 A3 INC DPTR Increment Pointer
8007 E0 MOVX A,@DPTR Get Next Byte

8008 A4 MUL AB Multiplication


Increment Pointer
8009 A3 INC DPTR To Store Result

800A F0 MOVX @DPTR,A Store The Result

16
Arunkumar KR, Reg.no 13160016

Move Carry To
800B E5,F0 MOV A,B Accumulator
Increment Pointer
800D A3 INC DPTR To Store Carry

800E F0 MOVX @DPTR,A Store The Carry

800F 02,80,0F LJMP 800F Wait Here

OUTPUT:

8100: 05 (Input 1)
8101: 02 (Input 2)
8102: 0A (Product LSB)
8103: 00 (Product MSB)

8100: FF (Input 1)
8101: FF (Input 2)
8102: 01 (Product LSB)
8103: FE (Product MSB)

RESULT:
The program to multiply two numbers using trainer kit was successfully executed and
obtained the output.

17
Arunkumar KR, Reg.no 13160016

EXPERIMENT NO: 5

DIVISION OF TWO NUMBERS IN 8051 TRAINER KIT

AIM:
Write an assembly language program to divide two digits numbers which are stored in
8100, 8101 and store the result in 8102 and reminder in 8103 using 8051 trainer kit.

ALGORITHM:
Step 01: Initially, store the two numbers in locations 8100 and 8101.
Step 02: Load the Data pointer with the address of the first number.
Step 03: Copy the number to accumulator and then to B.
Step 04: Increment the data pointer.
Step 05: Copy the next number into the accumulator.
Step 06: Divide the numbers in A and B.
Step 07: Increment the data pointer.
Step 08: Store the result in A to the memory location.
Step 09: Increment the data pointer.
Step 10: Copy the content in B to the accumulator.
Step 11: Move it to the memory location pointed by the data pointer.

PROGRAM CODE:

Memory Mnemonics Instruction Comment


Location
8000 90,81,100 MOV DPTR,#8100 Set Source Address
8003 E0 MOVX A,@DPTR Get First Byte
8004 F5,F0 MOV F0,A Store Temporarily
8006 A3 INC DPTR Increment Pointer
8007 E0 MOVX A,@DPTR Get Next Byte
8008 84 DIV AB Division
Increment Pointer To
8009 A3 INC DPTR Store

800A F0 MOVX @DPTR,A Store LSB Of Result

18
Arunkumar KR, Reg.no 13160016

800B E5,F0 MOV A,F0 Coping B To A


Increment Pointer To
800D A3 INC DPTR Store
800E F0 MOVX @DPTR,A Store MSB Of Result
800F 02,80,11 LJUMP 800F Wait Here

OUTPUT:

8100: 02 (Divisor)
8101: 06 (Dividend)
8102: 03 (Quotient)
8103: 00 (Remainder)

8100: 06 (Divisor)
8101: 02 (Dividend)
8102: 00 (Quotient)
8103: 02 (Remainder)

RESULT:
The program to divide two numbers using trainer kit was successfully executed
and obtained the output.

19
Arunkumar KR, Reg.no 13160016

Date: 23/07/2018
EXPERIMENT NO: 6

AVERAGE OF ‘N’ NUMBERS IN 8051 TRAINER KIT


AIM:
Write an assembly language program to find the average of N numbers where
N is count of numbers stored at location 8100 and numbers are stored from location
8101and store the average at next location.

ALGORITHM:
Step 01: Start
Step 02: Initially store the count value at location 8100 and numbers from 8101.
Step 03: Load data pointer with address 8100.
Step 04: Copy the first number to accumulator A and then to register R0.
Step 05: Copy the second number to register B.
Step 06: Clear the accumulator register R1 and carry.
Step 07: Increment data pointer and store data to accumulator.
Step 08: Add the accumulator along with carry and store to R1.
Step 09: Repeat the process from step 6 till the count become zero.
Step 10: Divide the sum with count and store to the next address.
Step 11: End.

PROGRAM CODE:

Memory Mnemonics Instruction Comment


Location
8000 90,81,100 MOV DPTR,#8100 Set Source Address
8003 E0 MOVX A,@DPTR Get First Byte
8004 F8 MOV R0,A Store Temporarily
8005 F5 MOV F0,A Copy To Register B
8006 F0 MOVX @DPTR,A Store The First Number
8007 74 MOV A,#00 Clear Accumulator
8009 79 MOV R1,#00 Clear Register
800B C3 CLR C Clear Carry

20
Arunkumar KR, Reg.no 13160016

800C A3 INC DPTR Increment Pointer


800D E0 MOVX A,@DPTR Store 2nd Number
800E 39 ADDC A,R1 Add With Carry
Store Sum To
800F F9 MOV R1,A Accumulator
8010 D8 DJNZ R0,800B
8012 84 DIV AB Divide
8013 A3 INC DPTR Increment Pointer
8014 F0 MOVX @DPTR,A Store Result
8015 80 SJMP 8000 Wait Here

OUTPUT:
8100: 05 (Count N)
8101: 01 (Num 1)
8102: 02 (Num 2)
8103: 03 (Num 3)
8104: 04 (Num 4)
8105: 05 (Num 5)
8106: 06 (Average)

RESULT:
The program to find average of ‘N’ numbers using 8051 trainer kit was
successfully executed and obtained the output.

21
Arunkumar KR, Reg.no 13160016

Date: 30/07/2018

EXPERIMENT NO: 7

ADDITION OF TWO NUMBERS


AIM:
Write an assembly language program to add two numbers (using Kiel µVision
Software) which is stored in 32h & 33h and store the sum in 34h & carry in 35h.

ALGORITHM:
Step 01: Start
Step 02: Initially store two numbers in location 32h and 33h.
Step 03: Move the numbers in accumulator (A) and register (R0).
Step 04: Add the numbers.
Step 05: Store the result which is in accumulator to 34h.
Step 06: Clear the accumulator and add carry to it.
Step 07: Store the carry which is in the accumulator to 35h.
Step 08: End.

PROGRAM CODE:
org 00h
start: mov a,32h ;Store 1st no
mov r0,33h ;Store 2nd no
add a,r0 ;Add
mov 34h,a ;Copy sum at location 34h
mov a,#00h ;Clear accumulator
mov 35h,a ;Add with carry
sjmp start ;Copy carry at location 35h
end

22
Arunkumar KR, Reg.no 13160016

OUTPUT:
d:0x32 = F3 (Num 1)
d:0x33 = F2 (Num 2)
d:0x34 = E5 (Sum)
d:0x35 = 01 (Carry)

RESULT:
The program to find sum of two number using Keil µVision Software is
executed and output was obtained.

23
Arunkumar KR, Reg.no 13160016

Date: 30/07/2018

EXPERIMENT NO: 8

ADDITION OF ‘N’ NUMBERS


AIM:
Write an assembly language program to add ‘N’ numbers (using Kiel µVision
Software) which count is stored in 32h and the sum in 49h.

ALGORITHM:
Step 01: Start
Step 02: Initially store the count N in location 32h.
Step 03: Copy data of 32h in register R1.
Step 04: Clear the accumulator.
Step 05: Increment R1.
Step 06: Add the data in accumulator with the data in address of R1.
Step 07: Until the count becomes zero, decrement R0 and jump to ‘step 05’.
Step 08: Store the sum from accumulator to 49h.
Step 09: End.

PROGRAM CODE:
org 00h
start: mov ro,32h ;Store count
mov r1,#32h ;Copt data in register R1
mov a,#00h ;Clear accumulator
label: inc r1 ;Increment count value
add a,@r1 ;Add
djnz r0, label ;Decrement to label if count !=0
mov 49h,a ;Store sum at 49h
end

24
Arunkumar KR, Reg.no 13160016

OUTPUT:
d:0x32 = 05 (Count)
d:0x33 = 01 (Num 1)
d:0x34 = 02 (Num 2)
d:0x35 = 03 (Num 3)
d:0x36 = 04 (Num 4)
d:0x37 = 05 (Num 5)
d:0x49 = 0F (Sum)

RESULT:
The program to ‘N’ number using Keil µVision Software is executed and
output was obtained.

25
Arunkumar KR, Reg.no 13160016

Date: 06/08/2018

EXPERIMENT NO: 9

ADDITION OF ‘N’ NUMBERS WITH CARRY


AIM:
Write an assembly language program to add ‘N’ numbers with carry (using Kiel
µVision Software) which count is stored in 32h, store the sum in 49h and carry in 50h.

ALGORITHM:
Step 01: Start
Step 02: Initially store the count N in location 32h.
Step 03: Copy data of 32h in register R1.
Step 04: Clear the accumulator (A).
Step 05: Clear the register R5.
Step 06: Increment R1.
Step 07: For each location in R1 store the data.
Step 08: Add the data with previous number in accumulator.
Step 09: If a carry is generated increment R5.
Step 10: Until the count is zero decrement R0 and jump to ‘Step 06’.
Step 11: Store the sum from the accumulator in 49h.
Step 12: Move the carry generated in R5 to the accumulator.
Step 13: Move the carry from the accumulator to 50h.
Step 14: End.

PROGRAM CODE:
Org 00h
Start: mov r0,32h
mov r1,#32h
mov a,#00h
mov r5,#00h
label: inc r1
add a,@r1
jc label1

26
Arunkumar KR, Reg.no 13160016

jnc label2
label1: inc r5
label2: djnz r0,label
mov 49h,a
mov a,r5
mov 50h,a
sjmp start

OUTPUT:
d:0x32 = 03 (Count)
d:0x33 = FF (Num 1)
d:0x34 = FE (Num 2)
d:0x35 = DA (Num 3)
d:0x49 = D7 (Sum)
d:0x50 = 02 (Carry)

RESULT:
The program to ‘N’ number with carry using Keil µVision Software is executed
and output was obtained.

27
Arunkumar KR, Reg.no 13160016

Date: 06/08/2018

EXPERIMENT NO: 10

ADDITION OF TWO NUMBERS GIVEN TO PORTS


AIM:
Write an assembly language program to add two numbers which are given
through ports (using Kiel µVision Software.

ALGORITHM:
Step 01: Start
Step 02: Set P0 & P1 as the input port.
Step 03: Set P2 & P3 as the output port.
Step 04: Move the data from P0 to the accumulator A.
Step 05: Move the data from P1 to the register R0.
Step 06: Add the numbers.
Step 07: Move the sum in the accumulator to Port2.
Step 08: End.

PROGRAM CODE:
org 00h
mov p0,#0FFh ;input port configuration
mov p1,#0FFh ;input port configuration
mov p2,#00h ;output port configuration
mov p3,#00h ;output port configuration

start: mov a,p0 ;copy data of P0 to accumulator


mov r0,p1 ;copy data of P1 to register R0
add a,ro ;add
mov p2,a ;copy sum to P2
mov a,#00h ; clear accumulator
addc a,#00h ;add with carry

28
Arunkumar KR, Reg.no 13160016

mov p3,a ; copy carry to P3


sjmp start

OUTPUT:
PORT P0: P0 0xFF
PINS 0xFF (Input 1)
PORT P1: P1 0xFF
PINS 0xFF (Input 2)
PORT P2: P0 0xFE
PINS 0xFE (Sum)
PORT P3: P0 0x01
PINS 0x01 (Carry)

RESULT:
The program to find sum of two numbers given to ports using Keil µVision
Software is executed and output was obtained.

29
Arunkumar KR, Reg.no 13160016

Date: 03/09/2018

EXPERIMENT NO: 11

FACTORIAL OF A NUMBER
AIM:
Write an assembly language program to find factorial of a number which is
given through ports (using Kiel µVision Software).Observe the output in Proteus
Design Suite Software.

ALGORITHM:
Step 01: Start
Step 02: Set P1 as input port & P3 as the output port.
Step 03: Move the number in R0 register given through Port1.
Step 04: Set the accumulator as 01h.
Step 05: Move the number to register B from R0 register.
Step 06: Multiply ‘A’ and ‘B’.
Step 07: Decrement R0 and until it becomes 0 and jump to ‘Step 06’.
Step 08: Move the factorial of number in A to Port3.
Step 09: End.

PROGRAM CODE:
org 00h
mov p1,#0FFh ;input port configuration
mov p3,#00h ;output port configuration

start: mov r0,p1 ;Move the no in R0 register given through Port1


mov a,#01h ;Set the accumulator as 01h.
label: mov b,r0 ;Move the no to register B from R0 register
mul ab ;Multiply ‘A’ and ‘B’
djnz r0,label
mov p3,a ;Move the output to Port3
sjmp start

30
Arunkumar KR, Reg.no 13160016

OUTPUT:

PORT P1: P1 0x05


PINS 0x05 (Input)
PORT P3: P3 0x78
PINS 0x78 (Factorial)

RESULT:
The program to find factorial of a number given to port using Keil µVision
Software is executed and output was verified in Proteus Design Suite.

31
Arunkumar KR, Reg.no 13160016

Date: 06/09/2018

EXPERIMENT NO: 12

SMALLEST OF N-NUMBERS
AIM:
Write an assembly language program to find smallest of N-number (using Kiel
µVision Software) where count is stored at 32h and numbers are stored from location
34h. Store the result at 33h.

ALGORITHM:
Step 01: Start
Step 02: Store count value at location 32h.
Step 03: Store the numbers starting from location 34h and copy it to R1.
Step 04: Copy first number to accumulator.
Step 05: Clear the carry and subtract content of accumulator and R1.
Step 06: Subtract the numbers till count is zero to get smaller numbers.
Step 07: Store result at location 33h.
Step 09: End.

PROGRAM CODE:
org 00h
start: mov r0,32h
dec r0
mov r1,#34h
mov a,34h
label1: clr c
inc r1
mov r5,a
subb a,@r1
jnc label2
jc label3

32
Arunkumar KR, Reg.no 13160016

label2: mov a,@r1


jmp label4
label3: mov a,r5
label4: djnz r0,label1
mov 33h,a
sjmp start
OUTPUT:

D:0x32 = 05 (Count)
D:0x34 = 01 (Input 1)
D:0x35 = 02 (Input 2)
D:0x36 = 03 (Input 3)
D:0x37 = 04 (Input 4)
D:0x38 = 05 (Input 5)
D:0x33 = 01 (Result)

RESULT:
The program to find factorial of a smallest of N-number using Keil µVision
Software is executed and output was verified.

33
Arunkumar KR, Reg.no 13160016

Date: 17/09/2018

EXPERIMENT NO: 13

BLINKING OF LED
AIM:
Write an assembly language program to blink a LED with time period 1 sec
(using Kiel µVision Software). Observe the output using Proteus Design Suite
software.

ALGORITHM:
Step 01: Start
Step 02: Configure Port-1 as output port.
Step 03: Set Port-1 as 1 to ON the LED.
Step 04: Call a delay function. Go to step 07.
Step 05: Set Port-1 as 0 to OFF the LED.
Step 06: Repeat step 04. Then go to step 03.
Step 07: Set delay for a 20 times loop. Move 14h to register r4.
Step 08: If the bit TF1 is nor set then repeat this step again.
Step 09: Clear TF1 and TR1.
Step 10: Until R4 is nor zero decrement R4 and jump to step 08.
Step 11: Return to delay function
Step 12: End.

PROGRAM CODE:
org 00h
mov p1,#00h
start: mov p1,#01h
lcall delay
mov p1,#00h
lcall delay
sjmp start

34
Arunkumar KR, Reg.no 13160016

delay:mov r4,#14h
label1:mov tmod,#10h
mov th1,#03ch
mov tl1,#0afh
setb tr1
label2: jnb tf1,label2
clr tf1
clr tr1
djnz r4,label1
ret
OUTPUT:
PORT 1 PORT1
P1: 0x01 → P1: 0x00
(After 500 ms)
PINS: 0x01 PINS: 0x00

35
Arunkumar KR, Reg.no 13160016

LED ON LED OFF

RESULT:
The program to blink a LED with time period 1 sec using Keil µVision
Software is executed and output was verified Proteus Design Suite.

36
Arunkumar KR, Reg.no 13160016

Date: 17/09/2018

EXPERIMENT NO: 14

TRAFFIC LIGHT CONTROL


AIM:
Write an assembly language program for traffic light control using the
following table for 4 different roads (using Kiel µVision Software). Observe the
output using Proteus Design Suite software.

4s 1s 4s 1s 4s 1s 4s 1s
R1 P1.7 0 0 1 1 1 1 1 0
ROAD 1 Y1 P1.6 0 1 0 0 0 0 0 1
G1 P1.5 1 0 0 0 0 0 0 0
R2 P1.4 1 0 0 0 1 1 1 1
ROAD 2 Y2 P1.3 0 1 0 1 0 0 0 0
G2 P1.2 0 0 1 0 0 0 0 0
R3 P1.1 1 1 1 0 0 0 1 1
ROAD 3 Y3 P1.0 0 0 0 1 0 1 0 0
G3 P2.3 0 0 0 0 1 0 0 0
R4 P2.2 1 1 1 1 1 0 0 0
ROAD 4 Y4 P2.1 0 0 0 0 0 1 0 1
G4 P2.0 0 0 0 0 0 0 1 0
P1 32H 4AH 86H 89H 90H 91H 92H 52H
P2 04H 04H 04H 04H 0CH 02H 01H 02H

ALGORITHM:
Step 01: Start
Step 02: Configure P1 and P2 as output port.
Step 03: Store in P1 & P2, 32h and 04h respectively and call delay of 4 seconds.
Step 04: Store in P1 & P2, 04ah and 04h respectively and call delay of 1 seconds.
Step 05: Store in P1 & P2, 86h and 04h respectively and call delay of 4 seconds.
Step 06: Store in P1 & P2, 89h and 04h respectively and call delay of 1seconds.
Step 07: Store in P1 & P2, 90h and 0ch respectively and call delay of 4 seconds.
Step 08: Store in P1 & P2, 91h and 02h respectively and call delay of 1 seconds.
Step 09: Store in P1 & P2, 92h and 01h respectively and call delay of 4seconds.
Step 10: Store in P1 & P2, 52h and 02h respectively and call delay of 1 seconds.

37
Arunkumar KR, Reg.no 13160016

Step 11: End.

PROGRAM CODE:
org 00h
mov p1,#00h
mov p2,#00h

start: mov p1,#32h


mov p2,#04h
lcall delay4
mov p1,#4ah
mov p2,#04h
lcall delay1
mov p1,#86h
mov p2,#04h
lcall delay4
mov p1,#89h
mov p2,#04h
lcall delay1
mov p1,#90h
mov p2,#0ch
lcall delay4
mov p1,#91h
mov p2,#02h
lcall delay1
mov p1,#92h
mov p2,#01h
lcall delay4
mov p1,#52h

38
Arunkumar KR, Reg.no 13160016

mov p2,#02h
lcall delay1
sjmp start

delay4:mov r4,#50h
l1: mov tmod,#10h
mov th1,#3ch
mov tl1,#0afh
setb tr1
l2: jnb tf1,l2
clr tf1
clr tr1
djnz r4,l1
ret

delay1:mov r4,#14h
l3: mov tmod,#10h
mov th1,#3ch
mov tl1,#0afh
setb tr1
l4: jnb tf1,l4
clr tf1
clr tr1
djnz r4,l3
ret
OUTPUT:

39
Arunkumar KR, Reg.no 13160016

4s→ 1s→ 4s→ 1s→ 4s→ 1s→ 4s→ 1s→


Port 1 32H 4AH 86H 89H 90H 91H 92H 52H
Port 2 04H 04H 04H 04H 0CH 02H 01H 02H

40
Arunkumar KR, Reg.no 13160016

41
Arunkumar KR, Reg.no 13160016

42
Arunkumar KR, Reg.no 13160016

RESULT:
The program for traffic light control using Keil µVision Software is executed
and output was verified Proteus Design Suite.

43
Arunkumar KR, Reg.no 13160016

Date: 08/10/2018

EXPERIMENT NO: 15

VOWEL DISPLAY
AIM:
Write an assembly language program to display vowels using 7 segment
display (using Kiel µVision Software). Observe the output using Proteus Design Suite
software with 7-Segment display.

Seven Segment Display


a b c d e f g HEX
VALUE
A 1 1 1 0 1 1 1 77h
E 1 0 0 1 1 1 1 4Fh
I 0 0 0 0 1 1 0 06h
O 1 1 1 1 1 1 0 7Eh
U 0 1 1 1 1 1 0 3Eh

ALGORITHM:
Step 01: Start
Step 02: Configure Port-1 as output port.
Step 03: move 300h to data pointer.
Step 04: Set 00h to register R2.
Step 05: Set 05h to register R7.
Step 06: Move R2 to the accumulator
Step 07: Move the data in the look up table pointed by the data pointer in the ath
position.
Step 08: Move the value in accumulator to port1.
Step 09: Increment R2 and call a delay for 1 second.
Step 10: End

PROGRAM CODE:
org 00h

44
Arunkumar KR, Reg.no 13160016

mov p1,#00h

start: mov dptr,#300h


mov r2,#00h
mov r0,#05h
loop: mov a,r2
movc a,@a+dptr
mov p1,a
inc r2
lcall delay
djnz r0,loop
sjmp start

delay:mov r4,#14h
l1: mov tmod,#10h
mov th1,#3ch
mov tl1,#0afh
setb tr1
l2: jnb tf1,l2
clr tf1
clr tr1
djnz r4,l1
ret

org 300h
db 77h,4fh,06h,7eh,3eh
end

OUTPUT:

45
Arunkumar KR, Reg.no 13160016

1s→ 1s→ 1s→ 1s→ 1s→


Port P1 77h 4Fh 06h 7Eh 3Eh

46
Arunkumar KR, Reg.no 13160016

47
Arunkumar KR, Reg.no 13160016

RESULT:
The program to display vowels using Keil µVision Software is executed and
output was verified Proteus Design Suite.

48
Arunkumar KR, Reg.no 13160016

Date: 08/10/2018

EXPERIMENT NO: 16

00-99 COUNTER
AIM:
Write an assembly language program that counts from 00-99 (using Kiel
µVision Software). Observe the output using Proteus Design Suite software with 7-
Segment display.

Seven Segment Display


a b c d e f g HEX
VALUE
0 1 1 1 1 1 1 0 7Eh
1 0 1 1 0 0 0 0 30h
2 1 1 0 1 1 0 1 6Dh
3 1 1 1 1 0 0 1 79h
4 0 1 1 0 0 1 1 33h
5 1 0 1 1 0 1 1 5Bh
6 1 0 1 1 1 1 1 5Fh
7 1 1 1 0 0 0 0 70h
8 1 1 1 1 1 1 1 7Fh
9 1 1 1 1 0 1 1 7Bh

ALGORITHM:
Step 01: Start
Step 02: Configure P1 & P2 as output port.
Step 03: Set R4 as 0Ah and set R5 as 00h.
Step 04: Move the data from 300h to the data pointer.
Step 05: Set register R3 as 0Ah.
Step 06: Move the value in register R5 to the accumulator A.
Step 07: Move the data from the code memory a+dptr to the accumulator A.
Step 08: Move the data from accumulator A to port P1.
Step 09: Clear the accumulator.
Step 10: Move the data from the code memory a+dptr to the accumulator A.
Step 11: Move the data from accumulator A to port P2.
Step 12: Increment the data pointer.

49
Arunkumar KR, Reg.no 13160016

Step 13: Call a delay function.


Step 14: Decrement R3 until it is not 0 and jump to step 09.
Step 15: Increment R5.
Step 16: Decrement R3 until it is not 0 and jump to step 04.
Step 17: End

PROGRAM CODE:
org 00h
mov p2,#00h
mov p1,#00h
start: mov r4,#0ah
mov r5,#00h
label1:mov dptr,#300h
mov r3,#0ah
mov a,r5
movc a,@a+dptr
mov p1,a
label2:clr a
movc a,@a+dptr
mov p2,a
inc dptr
lcall delay
djnz r3,label2
inc r5
djnz r4,label1
sjmp start

delay:mov r6,#14h
label3: mov tmod,#10h
mov th1,#03ch
mov tl1,#0ach
setb tr1

50
Arunkumar KR, Reg.no 13160016

label4:jnb tf1,label4
clr tf1
clr tr1
djnz r6,label3
ret

org 300h
db 7eh,30h,6dh,79h,33h,5bh,5fh,70h,7fh,7bh

end

OUTPUT:
Port 1 Port 2
7E 7E 00
7E 30 01
↓ ↓
↓ ↓
7E 7B 09
30 7E 10
↓ ↓
↓ ↓
7B 7B 99
7E 7E 00

51
Arunkumar KR, Reg.no 13160016

52
Arunkumar KR, Reg.no 13160016

53
Arunkumar KR, Reg.no 13160016

RESULT:
The program to counts from 00-99 Keil µVision Software is executed and
output was verified Proteus Design Suite.

54
Arunkumar KR, Reg.no 13160016

Date: 22/10/2018

EXPERIMENT NO: 17

DISPLAY NAME ON LCD DISPLAY


AIM:
Write an assembly language program for display your name in LCD (using
Kiel µVision Software). Observe the output using Proteus Design Suite software with
7-Segment display.

ALGORITHM:
Step 01: Start
Step 02: Configure P1 & P2 as output port.
Step 03: To initialize the LCD screen move 38h to the accumulator. Call the command
write function and then call delay function.
Step 04: To make the display on and curser blinking move 0Eh to the accumulator.
Call the command write function and then call elay function.
Step 05: To clear the LCD screen move 01h to the accumulator. Call the command
write function and then call delay function.
Step 06: To shift the cursor to the right of the LCD screen move 06h to the
accumulator. Call the command write function and then call delay function.
Step 07: To shift the cursor at line 1 position 4 move 84h to the accumulator. Call the
command write function and then call delay function.
Step 08: Move ASCII value of first character of name to the accumulator. Call the data
write function and then call delay function.
Step 09: Repeat the Step 08 for displaying next character.
Step 10: End.

PROGRAM CODE:

org 00h
mov p1,#00h
mov p2,#00h
mov a,#38h
acall comwrt

55
Arunkumar KR, Reg.no 13160016

acall delay
mov a,#0eh
acall comwrt
acall delay
mov a,#01h
acall comwrt
acall delay
mov a,#06h
acall comwrt
acall delay
mov a,#80h
acall comwrt
acall delay

start: mov a,#'A'


acall datwrt
acall delay
mov a,#'R'
acall datwrt
acall delay
mov a,#'U'
acall datwrt
acall delay
mov a,#'N'
acall datwrt
acall delay
mov a,#'K '
acall datwrt
acall delay
mov a,#'U'
acall datwrt
acall delay

56
Arunkumar KR, Reg.no 13160016

mov a,#'M'
acall datwrt
acall delay
mov a,#'A '
acall datwrt
acall delay
mov a,#'R'
acall datwrt
acall delay

mov a,#0c0h
acall comwrt
acall delay
l1: sjmp l1

comwrt:mov p1,a
clr p2.0
clr p2.1
setb p2.2
acall delay
clr p2.2
ret
datwrt: mov p1,a
setb p2.0
clr p2.1
setb p2.2
acall delay
clr p2.2
ret
delay: mov r3,#50h
label2:mov r4,#0ffh
label1:djnz r4,label1

57
Arunkumar KR, Reg.no 13160016

djnz r3,label2
ret

OUTPUT:

RESULT:
The program to display your name in LCD Keil µVision Software is executed
and output was verified Proteus Design Suite.

58
Arunkumar KR, Reg.no 13160016

Date: 22/10/2018

EXPERIMENT NO: 18

STEPPER MOTOR
AIM:
Write an assembly language to rotate stepper motor in clockwise direction
(using Kiel µVision Software). Observe the output using Proteus Design Suite
software.

ALGORITHM:
Step 01: Start
Step 02: Configure P1 as output port.
Step 03: To initialize the value 33h to the accumulator. Call the command “RL” or
rotate left function to rotate to the value to obtain the motion.
Step 04: Call the rotate left function and then call delay function.
Step 05: End.

PROGRAM CODE:

org 00h
mov p1,#0ffh
mov a,#33h
start:
rl a
acall delay
mov p1,a
sjmp start
delay: mov r0,#50h
l2: mov r4,#0ffh
l1:djnz r4,l1
djnz r3,l2
ret

59
Arunkumar KR, Reg.no 13160016

OUTPUT:

RESULT:
The program to rotate stepper motor was done in Keil µVision Software is
executed and output was verified Proteus Design Suite.

60

You might also like